1-----------------------------------------------------------------------
2--               GtkAda - Ada95 binding for Gtk+/Gnome               --
3--                                                                   --
4--      Copyright (C) 2000 E. Briot, J. Brobecker and A. Charlet     --
5--                Copyright (C) 2000-2006 AdaCore                    --
6--                                                                   --
7-- This library is free software; you can redistribute it and/or     --
8-- modify it under the terms of the GNU General Public               --
9-- License as published by the Free Software Foundation; either      --
10-- version 2 of the License, or (at your option) any later version.  --
11--                                                                   --
12-- This library is distributed in the hope that it will be useful,   --
13-- but WITHOUT ANY WARRANTY; without even the implied warranty of    --
14-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --
15-- General Public License for more details.                          --
16--                                                                   --
17-- You should have received a copy of the GNU General Public         --
18-- License along with this library; if not, write to the             --
19-- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --
20-- Boston, MA 02111-1307, USA.                                       --
21--                                                                   --
22-- As a special exception, if other files instantiate generics from  --
23-- this unit, or you link this unit with other files to produce an   --
24-- executable, this  unit  does not  by itself cause  the resulting  --
25-- executable to be covered by the GNU General Public License. This  --
26-- exception does not however invalidate any other reasons why the   --
27-- executable file  might be covered by the  GNU Public License.     --
28-----------------------------------------------------------------------
29
30--  <description>
31--  A Gtk_Sheet is a table like the one you can find in most spreadsheets.
32--  Each cell can contain some text or any kind of widgets.
33--  </description>
34--  <c_version>gtkextra 2.1.1</c_version>
35--  <group>GtkExtra, additional widgets</group>
36--  <testgtk>create_sheet.adb</testgtk>
37--  <screenshot>gtk-sheet</screenshot>
38
39with Gtk.Adjustment;  use Gtk.Adjustment;
40with Gtk.Container;
41with Gtk.Enums;       use Gtk.Enums;
42with Gtk.GEntry;
43with Gdk.Rectangle;
44with Gdk.Color;
45with Gdk.GC;
46with Pango.Font;
47with Gtk.Widget;
48
49package Gtk.Extra.Sheet is
50
51   type Gtk_Sheet_Record is new Gtk.Container.Gtk_Container_Record
52     with private;
53   type Gtk_Sheet is access all Gtk_Sheet_Record'Class;
54
55   type Gtk_Sheet_Range_Record is record
56      Row0, Col0 : Gint;  --  Upper-left cell
57      Rowi, Coli : Gint;  --  Lower-Right cell
58   end record;
59
60   type Gtk_Sheet_Range is access all Gtk_Sheet_Range_Record;
61   --  A range in the sheet.
62   --  This is a part of the sheet represented by its upper-left cell and
63   --  its lower-right cell.
64   --  Most operations below apply to such ranges.
65
66   type Gtk_Sheet_Child_Record is
67     new Gtk.Widget.Gtk_Widget_Record with private;
68   type Gtk_Sheet_Child is access all Gtk_Sheet_Child_Record'Class;
69   --  A widget insert in the sheet.
70   --  This structure includes both a widget pointer and the position in the
71   --  table in which it is put.
72
73   ----------------
74   -- Enum types --
75   ----------------
76
77   --  <doc_ignore>
78   type Sheet_Attr_Type is
79     (Sheet_Foreground,
80      Sheet_Background,
81      Sheet_Font,
82      Sheet_Justification,
83      Sheet_Border,
84      Sheet_Border_Color,
85      Sheet_Is_Editable,
86      Sheet_Is_Visible);
87   --  Attributes that can be set for the sheet.
88   --  No function is provided at the Ada level to modify these attributes
89   --  directly.
90   pragma Convention (C, Sheet_Attr_Type);
91   --  </doc_ignore>
92
93   type Sheet_State is
94     (Sheet_Normal,
95      Sheet_Row_Selected,
96      Sheet_Column_Selected,
97      Sheet_Range_Selected);
98   --  The state of the selection.
99   pragma Convention (C, Sheet_State);
100
101   type Gtk_Sheet_Border is new Integer;
102   --  Mask that indicates which borders should be visible in a cell.
103
104   No_Border     : constant Gtk_Sheet_Border;
105   Left_Border   : constant Gtk_Sheet_Border;
106   Right_Border  : constant Gtk_Sheet_Border;
107   Top_Border    : constant Gtk_Sheet_Border;
108   Bottom_Border : constant Gtk_Sheet_Border;
109   All_Borders   : constant Gtk_Sheet_Border;
110
111   -------------------------------
112   -- Creation and modification --
113   -------------------------------
114
115   procedure Gtk_New
116     (Sheet      : out Gtk_Sheet;
117      Rows       : Guint;
118      Columns    : Guint;
119      Title      : UTF8_String := "";
120      Entry_Type : Gtk_Type := GType_Invalid);
121   --  Create a new sheet with a specific number of rows and columns.
122   --  You can fully specify which type the entry used to modify the value of
123   --  cells should have. The value of Entry_Type can be found by using one
124   --  of the Get_Type subprograms in the GtkAda packages.
125   --  The Title is internal, and does not appear on the screen.
126
127   procedure Initialize
128     (Sheet      : access Gtk_Sheet_Record'Class;
129      Rows       : Guint;
130      Columns    : Guint;
131      Title      : UTF8_String := "";
132      Entry_Type : Gtk_Type := GType_Invalid);
133   --  Internal initialization function.
134   --  See the section "Creating your own widgets" in the documentation.
135
136   procedure Gtk_New_Browser
137     (Sheet   : out Gtk_Sheet;
138      Rows    : Guint;
139      Columns : Guint;
140      Title   : UTF8_String := "");
141   --  Create a new sheet browser with a specific number of rows and columns.
142   --  This is a standard Gtk_Sheet, except that it is read-only and that its
143   --  cells will automatically resize themselves depending on their contents.
144
145   procedure Initialize_Browser (Sheet   : access Gtk_Sheet_Record'Class;
146                                 Rows    : in Guint;
147                                 Columns : in Guint;
148                                 Title   : in UTF8_String := "");
149   --  Internal initialization function.
150   --  See the section "Creating your own widgets" in the documentation.
151
152   function Get_Type return Gtk.Gtk_Type;
153   --  Return the internal value associated with a Gtk_Sheet.
154
155   procedure Set_Hadjustment
156     (Sheet      : access Gtk_Sheet_Record;
157      Adjustment : access Gtk_Adjustment_Record'Class);
158   --  Change the horizontal adjustment.
159   --  It indicates what range of columns is visible.
160
161   procedure Set_Vadjustment
162      (Sheet      : access Gtk_Sheet_Record;
163       Adjustment : access Gtk_Adjustment_Record'Class);
164   --  Change the vertical adjustment.
165   --  It indicates what range of rows is visible.
166
167   function Get_Vadjustment
168     (Sheet  : access Gtk_Sheet_Record)
169      return      Gtk.Adjustment.Gtk_Adjustment;
170   --  Return the adjustment used to indicate the range of visible rows.
171
172   function Get_Hadjustment
173     (Sheet  : access Gtk_Sheet_Record)
174      return      Gtk.Adjustment.Gtk_Adjustment;
175   --  Return the adjustment used to indicate the range of visible columns.
176
177   procedure Change_Entry
178     (Sheet      : access Gtk_Sheet_Record;
179      Entry_Type : Gtk_Type);
180   --  Change the type of widget used to interactively modify the value of
181   --  the cells.
182
183   function Get_Entry
184     (Sheet : access Gtk_Sheet_Record) return Gtk.GEntry.Gtk_Entry;
185   --  Return the entry used to modify the content of the cells.
186   --  This can be the same widget as Get_Entry_Widget, if set, or some default
187   --  widget associated with the specific child otherwise
188
189   function Get_Entry_Widget
190     (Sheet : access Gtk_Sheet_Record) return Gtk.Widget.Gtk_Widget;
191   --  Return the entry used to modify the content of the cells.
192
193   procedure Set_Title
194     (Sheet : access Gtk_Sheet_Record;
195      Title : UTF8_String);
196   --  Change the title of the sheet.
197
198   procedure Freeze (Sheet : access Gtk_Sheet_Record);
199   --  Freeze all visual updates of the sheet, until you thaw it.
200   --  The update will occur in a more efficient way.
201
202   procedure Thaw (Sheet : access Gtk_Sheet_Record);
203   --  Thaw the sheet, so that visual updates occur again.
204   --  Note that you have to call Thaw as many times as you have called
205   --  Freeze to actually thaw the widget.
206
207   procedure Moveto
208     (Sheet     : access Gtk_Sheet_Record;
209      Row       : Gint;
210      Column    : Gint;
211      Row_Align : Gfloat;
212      Col_Align : Gfloat);
213   --  Scroll the viewing area to (Row, Column).
214   --  (Row_Align, Col_Align) represent the location on the screen that the
215   --  cell should appear at. (0.0, 0.0) is at the top-left of the screen,
216   --  whereas (1.0, 1.0) is at the bottom-right corner.
217   --  If Row or Column is negative, there is no change.
218
219   procedure Set_Background
220     (Sheet : access Gtk_Sheet_Record; Color : Gdk.Color.Gdk_Color);
221   --  Change the background color of the cells.
222
223   procedure Set_Grid
224     (Sheet : access Gtk_Sheet_Record; Color : Gdk.Color.Gdk_Color);
225   --  Set the color to use for the grid.
226
227   procedure Show_Grid
228     (Sheet : access Gtk_Sheet_Record; Show : Boolean);
229   --  Whether the grid should be made visible
230
231   function Grid_Visible (Sheet : access Gtk_Sheet_Record) return Boolean;
232   --  Whether the grid is currently visible
233
234   ----------------------------
235   -- Selection and Clipping --
236   ----------------------------
237
238   function Get_State (Sheet : access Gtk_Sheet_Record) return Sheet_State;
239   --  Return the status of the selection in the sheet.
240
241   function Get_Range (Sheet : access Gtk_Sheet_Record) return Gtk_Sheet_Range;
242   --  Return the selected range.
243
244   procedure Get_Visible_Range
245     (Sheet     : access Gtk_Sheet_Record;
246      The_Range : out Gtk_Sheet_Range);
247   --  Return the range visible on the screen.
248
249   procedure Set_Selection_Mode
250     (Sheet : access Gtk_Sheet_Record;
251      Mode  : Gtk.Enums.Gtk_Selection_Mode);
252   --  Change the selection mode.
253
254   procedure Select_Column
255     (Sheet  : access Gtk_Sheet_Record;
256      Column : Gint);
257   --  Replace the current selection with a specific column.
258   --  The range is highlighted.
259
260   procedure Select_Row
261     (Sheet : access Gtk_Sheet_Record;
262      Row   : Gint);
263   --  Replace the current selection with a specific row.
264   --  The range is highlighted.
265
266   procedure Set_Autoresize
267     (Sheet : access Gtk_Sheet_Record; Autoresize : Boolean);
268   --  Whether cells should automatically resize to fit their contents
269
270   function Autoresize (Sheet : access Gtk_Sheet_Record) return Boolean;
271   --  Whether cells automatically resize to fit their contents
272
273   procedure Set_Autoscroll
274     (Sheet : access Gtk_Sheet_Record; Autoscroll : Boolean);
275   --  Whether the sheet should automatically scroll to show the active cell at
276   --  all times.
277
278   function Autoscroll (Sheet : access Gtk_Sheet_Record) return Boolean;
279   --  Whether the sheet automatically scrolls to show the active cell at all
280   --  times.
281
282   procedure Set_Clip_Text
283     (Sheet : access Gtk_Sheet_Record; Clip : Boolean);
284   --  Set when the text contained in the cells is automatically clipped to
285   --  their width.
286
287   function Clip_Text (Sheet : access Gtk_Sheet_Record) return Boolean;
288   --  Whether the text contained in the cells is automatically clipped to
289   --  their width.
290
291   procedure Set_Justify_Entry
292     (Sheet : access Gtk_Sheet_Record; Justify_Entry : Boolean);
293   --  Set when the justification attribute for entries should be taken into
294   --  account
295
296   function Justify_Entry (Sheet : access Gtk_Sheet_Record) return Boolean;
297   --  Whether the justification attribute is used for entries
298
299   procedure Set_Locked
300     (Sheet : access Gtk_Sheet_Record; Locked : Boolean);
301   --  If Locked is true, the cells are no longer editable
302
303   function Locked (Sheet : access Gtk_Sheet_Record) return Boolean;
304   --  Whether cells are currently read-only
305
306   procedure Select_Range
307     (Sheet     : access Gtk_Sheet_Record;
308      The_Range : Gtk_Sheet_Range);
309   --  Select a new range of cells.
310
311   procedure Unselect_Range (Sheet : access Gtk_Sheet_Record);
312   --  Unselect a specific range of cells.
313   --  If null is passed, the current selected range is used.
314
315   procedure Clip_Range (Sheet     : access Gtk_Sheet_Record;
316                         The_Range : in Gtk_Sheet_Range);
317   --  Create a new clip range, which is copied to the clipboard
318   --  That range is flashed on the screen.
319
320   procedure Unclip_Range (Sheet : access Gtk_Sheet_Record);
321   --  Destroy the clip area.
322
323   function In_Clip (Sheet : access Gtk_Sheet_Record) return Boolean;
324   --  Whether a range was copied to the clipboard
325
326   function Set_Active_Cell
327     (Sheet  : access Gtk_Sheet_Record;
328      Row    : Gint;
329      Column : Gint)
330      return Boolean;
331   --  Set active cell where the entry will be displayed.
332   --  Returns FALSE if the current cell can not be deactivated or if the
333   --  requested cell can't be activated.
334   --  Depending on the value passed to Set_Autoscroll, the sheet might be
335   --  scrolled.
336
337   procedure Get_Active_Cell
338     (Sheet  : access Gtk_Sheet_Record;
339      Row    : out Gint;
340      Column : out Gint);
341   --  Return the coordinates of the active cell.
342   --  This is the cell that the user is currently editing.
343
344   -------------
345   -- Columns --
346   -------------
347
348   procedure Set_Column_Title
349     (Sheet  : access Gtk_Sheet_Record;
350      Column : Gint;
351      Title  : UTF8_String);
352   --  Modify the title of a column.
353   --  The first column on the left has the number 0.
354   --  Note that this title does not appear on the screen, and can only be
355   --  used internally to find a specific column.
356
357   function Get_Column_Title
358     (Sheet  : access Gtk_Sheet_Record;
359      Column : Gint) return UTF8_String;
360   --  Return the title of a specific column.
361
362   procedure Set_Column_Titles_Height
363     (Sheet  : access Gtk_Sheet_Record; Height : Guint);
364   --  Modify the height of the row in which the column titles appear.
365
366   procedure Column_Button_Add_Label
367     (Sheet  : access Gtk_Sheet_Record;
368      Column : Gint;
369      Label  : UTF8_String);
370   --  Modify the label of the button that appears at the top of each column.
371
372   function Column_Button_Get_Label
373     (Sheet : access Gtk_Sheet_Record; Column : Gint) return UTF8_String;
374   --  Return the label for the button that appears at the top of each column
375
376   procedure Column_Button_Justify
377      (Sheet         : access Gtk_Sheet_Record;
378       Column        : Gint;
379       Justification : Gtk.Enums.Gtk_Justification);
380   --  Modify the justification for the label in the column button.
381
382   procedure Show_Column_Titles (Sheet : access Gtk_Sheet_Record);
383   --  Show the row in which the column titles appear.
384
385   procedure Hide_Column_Titles (Sheet : access Gtk_Sheet_Record);
386   --  Hide the row in which the column titles appear.
387
388   function Column_Titles_Visible
389     (Sheet : access Gtk_Sheet_Record) return Boolean;
390   --  Whether a special row is added at the top to show the title of the
391   --  columns.
392
393   procedure Columns_Set_Sensitivity
394     (Sheet     : access Gtk_Sheet_Record;
395      Sensitive : Boolean);
396   --  Modify the sensitivity of all the columns.
397   --  If Sensitive is False, the columns can not be resized dynamically.
398   --  This also modifies the sensitivity of the button at the top of the
399   --  columns.
400
401   procedure Column_Set_Sensitivity
402     (Sheet     : access Gtk_Sheet_Record;
403      Column    : Gint;
404      Sensitive : Boolean);
405   --  Modify the sensitivity of a specific column and its title button.
406   --  If Sensitive if False, the column can not be dynamically resized.
407
408   procedure Column_Set_Visibility
409     (Sheet   : access Gtk_Sheet_Record;
410      Column  : Gint;
411      Visible : Boolean);
412   --  Change the visibility of a column.
413
414   procedure Columns_Set_Resizable
415     (Sheet : access Gtk_Sheet_Record; Resizable : Boolean);
416   --  Whether columns are resizable
417
418   function Columns_Resizable (Sheet : access Gtk_Sheet_Record) return Boolean;
419   --  Whether columns are resizable
420
421   procedure Column_Label_Set_Visibility
422     (Sheet   : access Gtk_Sheet_Record;
423      Column  : Gint;
424      Visible : Boolean := True);
425   --  Change the visibility of the label in a given column.
426
427   procedure Columns_Labels_Set_Visibility
428     (Sheet   : access Gtk_Sheet_Record;
429      Visible : Boolean := True);
430   --  Change the visibility for all the column labels.
431
432   procedure Set_Column_Width
433     (Sheet  : access Gtk_Sheet_Record;
434      Column : Gint;
435      Width  : Guint);
436   --  Modify the width in pixels of a specific column.
437
438   function Get_Column_Width (Sheet  : access Gtk_Sheet_Record;
439                              Column : in Gint)
440                             return Gint;
441   --  Return the width in pixels of the Column-nth in Sheet.
442
443   procedure Add_Column
444     (Sheet : access Gtk_Sheet_Record;
445      Ncols : Guint);
446   --  Add some empty columns at the end of the sheet.
447
448   procedure Insert_Columns
449     (Sheet : access Gtk_Sheet_Record;
450      Col   : Guint;
451      Ncols : Guint);
452   --  Add Ncols empty columns just before the columns number Col.
453
454   procedure Delete_Columns
455     (Sheet : access Gtk_Sheet_Record;
456      Col   : Guint;
457      Ncols : Guint);
458   --  Delete Ncols columns starting from Col.
459
460   procedure Column_Set_Justification
461     (Sheet         : access Gtk_Sheet_Record;
462      Column        : Gint;
463      Justification : Gtk.Enums.Gtk_Justification);
464   --  Set the default justification for the cells in the specific column.
465
466   function Get_Columns_Count (Sheet : access Gtk_Sheet_Record) return Guint;
467   --  Return the maximum column number of the displayed cells.
468
469   ----------
470   -- Rows --
471   ----------
472
473   procedure Set_Row_Title
474     (Sheet : access Gtk_Sheet_Record;
475      Row   : Gint;
476      Title : UTF8_String);
477   --  Modify the title of a row.
478   --  The first row at the top has the number 0.
479   --  Note that this title does not appear on the screen, and can only be
480   --  used internally to find a specific row.
481
482   function Get_Row_Title
483     (Sheet  : access Gtk_Sheet_Record; Row : Gint) return UTF8_String;
484   --  Return the title of a specific row.
485
486   procedure Set_Row_Titles_Width
487     (Sheet : access Gtk_Sheet_Record; Width : Guint);
488   --  Modify the width of the column that has the row titles.
489
490   procedure Row_Button_Add_Label
491     (Sheet : access Gtk_Sheet_Record;
492      Row   : Gint;
493      Label : UTF8_String);
494   --  Modify the label of the button that appears on the left of each row.
495
496   function Row_Button_Get_Label
497     (Sheet : access Gtk_Sheet_Record; Row : Gint) return UTF8_String;
498   --  Return the label for the button that appears on the left of each row.
499
500   procedure Row_Button_Justify
501      (Sheet         : access Gtk_Sheet_Record;
502       Row           : Gint;
503       Justification : Gtk.Enums.Gtk_Justification);
504   --  Modify the justification for the label of the row button.
505
506   procedure Show_Row_Titles (Sheet : access Gtk_Sheet_Record);
507   --  Show the column in which the row titles appear.
508
509   procedure Hide_Row_Titles (Sheet : access Gtk_Sheet_Record);
510   --  Hide the column in which the row titles appear.
511
512   function Row_Titles_Visible
513     (Sheet : access Gtk_Sheet_Record) return Boolean;
514   --  Whether a special column is added to the left to show the title of the
515   --  rows.
516
517   procedure Rows_Set_Sensitivity (Sheet     : access Gtk_Sheet_Record;
518                                   Sensitive : in Boolean);
519   --  Modify the sensitivity of all the rows.
520   --  If Sensitive is False, the rows can not be resized dynamically.
521   --  This also modifies the sensitivity of the button at the left of the
522   --  row.
523
524   procedure Row_Set_Sensitivity (Sheet     : access Gtk_Sheet_Record;
525                                  Row       : in Gint;
526                                  Sensitive : in Boolean);
527   --  Modify the sensitivity of a specific row and its title button.
528   --  If Sensitive if False, the row can not be dynamically resized.
529
530   procedure Row_Set_Visibility (Sheet   : access Gtk_Sheet_Record;
531                                 Row     : in Gint;
532                                 Visible : in Boolean);
533   --  Modify the visibility of a specific row
534
535   procedure Row_Label_Set_Visibility
536     (Sheet   : access Gtk_Sheet_Record;
537      Row    : in Gint;
538      Visible : in Boolean := True);
539   --  Change the visibility of the label in a given Row.
540
541   procedure Rows_Labels_Set_Visibility
542     (Sheet   : access Gtk_Sheet_Record;
543      Visible : Boolean := True);
544   --  Change the visibility for all the row labels.
545
546   procedure Rows_Set_Resizable
547     (Sheet : access Gtk_Sheet_Record; Resizable : Boolean);
548   --  Whether rows are resizable
549
550   function Rows_Resizable (Sheet : access Gtk_Sheet_Record) return Boolean;
551   --  Whether rows are resizable
552
553   procedure Set_Row_Height
554     (Sheet  : access Gtk_Sheet_Record;
555      Row    : Gint;
556      Height : Guint);
557   --  Set the height in pixels of a specific row.
558
559   function Get_Row_Height (Sheet   : access Gtk_Sheet_Record;
560                            Row     : in Gint)
561                           return Gint;
562   --  Return the height in pixels of the Row-th row in Sheet.
563
564   procedure Add_Row
565     (Sheet : access Gtk_Sheet_Record;
566      Nrows : Guint);
567   --  Append Nrows row at the end of the sheet.
568
569   procedure Insert_Rows
570     (Sheet : access Gtk_Sheet_Record;
571      Row   : Guint;
572      Nrows : Guint);
573   --  Add Nrows empty rows just before the row number Row.
574
575   procedure Delete_Rows
576     (Sheet : access Gtk_Sheet_Record;
577      Row   : Guint;
578      Nrows : Guint);
579   --  Delete Nrows rows starting from Row.
580
581   function Get_Rows_Count (Sheet : access Gtk_Sheet_Record) return Guint;
582   --  Return the maximum row number of displayed cells.
583
584   -----------
585   -- Range --
586   -----------
587
588   function Range_Get_Type return Gtk.Gtk_Type;
589   --  Return the internal value associate with a Gtk_Sheet_Range
590
591   procedure Range_Clear
592     (Sheet     : access Gtk_Sheet_Record;
593      The_Range : Gtk_Sheet_Range);
594   --  Clear the content of the range.
595
596   procedure Range_Delete
597     (Sheet     : access Gtk_Sheet_Record;
598      The_Range : Gtk_Sheet_Range);
599   --  Clear the content of the range and delete all the links (user_data)
600
601   procedure Range_Set_Background
602     (Sheet     : access Gtk_Sheet_Record;
603      The_Range : Gtk_Sheet_Range;
604      Color     : Gdk.Color.Gdk_Color);
605   --  Set the background color for the cells in a specific range.
606
607   procedure Range_Set_Foreground
608     (Sheet     : access Gtk_Sheet_Record;
609      The_Range : Gtk_Sheet_Range;
610      Color     : Gdk.Color.Gdk_Color);
611   --  Set the foreground color for the cells in a specific range.
612
613   procedure Range_Set_Justification
614     (Sheet         : access Gtk_Sheet_Record;
615      The_Range     : Gtk_Sheet_Range;
616      Justification : Gtk.Enums.Gtk_Justification);
617   --  Set the text justification for the cells in the range.
618
619   procedure Range_Set_Editable
620     (Sheet     : access Gtk_Sheet_Record;
621      The_Range : Gtk_Sheet_Range;
622      Editable  : Boolean);
623   --  Set whether the cells in the range are editable.
624
625   procedure Range_Set_Visible (Sheet     : access Gtk_Sheet_Record;
626                                The_Range : in Gtk_Sheet_Range;
627                                Visible   : in Boolean);
628   --  Set whether the cells in the range are visible.
629
630   procedure Range_Set_Border
631     (Sheet      : access Gtk_Sheet_Record;
632      The_Range  : Gtk_Sheet_Range;
633      Mask       : Gtk_Sheet_Border;
634      Width      : Guint;
635      Line_Style : Gdk.GC.Gdk_Line_Style);
636   --  Set the style of the border for the cells in the range.
637
638   procedure Range_Set_Border_Color
639     (Sheet     : access Gtk_Sheet_Record;
640      The_Range : Gtk_Sheet_Range;
641      Color     : Gdk.Color.Gdk_Color);
642   --  Change the color for the borders of the cells in the range.
643
644   procedure Range_Set_Font
645     (Sheet     : access Gtk_Sheet_Record;
646      The_Range : Gtk_Sheet_Range;
647      Font      : Pango.Font.Pango_Font_Description);
648   --  Change the font of the cells in the range.
649
650   -----------
651   -- Cells --
652   -----------
653
654   procedure Set_Cell
655     (Sheet         : access Gtk_Sheet_Record;
656      Row           : Gint;
657      Col           : Gint;
658      Justification : Gtk.Enums.Gtk_Justification;
659      Text          : UTF8_String);
660   --  Set the cell contents.
661   --  Set Text to the empty string to delete the content of the cell.
662
663   procedure Set_Cell_Text
664     (Sheet : access Gtk_Sheet_Record;
665      Row   : Gint;
666      Col   : Gint;
667      Text  : UTF8_String);
668   --  Set the cell contents.
669   --  The justification used is the previous one used in that cell.
670
671   function Cell_Get_Text
672     (Sheet  : access Gtk_Sheet_Record;
673      Row    : Gint;
674      Col    : Gint)
675      return UTF8_String;
676   --  Return the text put in a specific cell.
677   --  The empty string is returned if there is no text in that cell.
678
679   procedure Cell_Clear
680     (Sheet : access Gtk_Sheet_Record;
681      Row   : Gint;
682      Col   : Gint);
683   --  Clear the contents of the cell.
684
685   procedure Cell_Delete
686     (Sheet : access Gtk_Sheet_Record;
687      Row   : Gint;
688      Col   : Gint);
689   --  Clear the contents of the cell and remove the user data associated
690   --  with it.
691
692   function Cell_Get_State (Sheet  : access Gtk_Sheet_Record;
693                            Row    : in Gint;
694                            Col    : in Gint)
695                           return  Gtk.Enums.Gtk_State_Type;
696   --  Return the state of the cell (normal or selected).
697
698   procedure Get_Pixel_Info
699     (Sheet  : access Gtk_Sheet_Record;
700      X      : Gint;
701      Y      : Gint;
702      Row    : out Gint;
703      Column : out Gint);
704   --  Return the row and column matching a given pixel on the screen.
705   --  Constraint_Error is raised if no such cell exists.
706
707   procedure Get_Cell_Area
708     (Sheet  : access Gtk_Sheet_Record;
709      Row    : Gint;
710      Column : Gint;
711      Area   : out Gdk.Rectangle.Gdk_Rectangle);
712   --  Get the area of the screen that a cell is mapped to.
713   --  Constraint_Error is raised if no such cell exists;
714
715   --------------
716   -- Children --
717   --------------
718   --  A Gtk_Sheet can contain some children, attached to some specific
719   --  cells.
720
721   procedure Put
722     (Sheet  : access Gtk_Sheet_Record;
723      Widget : access Gtk.Widget.Gtk_Widget_Record'Class;
724      X      : Gint;
725      Y      : Gint);
726   --  Put a new child at a specific location (in pixels) in the sheet.
727
728   procedure Attach
729      (Sheet    : access Gtk_Sheet_Record;
730       Widget   : access Gtk.Widget.Gtk_Widget_Record'Class;
731       Row      : Gint;
732       Col      : Gint;
733       Xoptions : Gtk.Enums.Gtk_Attach_Options := Expand or Fill;
734       Yoptions : Gtk.Enums.Gtk_Attach_Options := Expand or Fill;
735       Xpadding : Gint := 0;
736       Ypadding : Gint := 0);
737   --  Attach a child to a specific Cell in the sheet.
738   --  X_Align and Y_Align should be between 0.0 and 1.0, indicating that
739   --  the child should be aligned from the Left (resp. Top) to the Right
740   --  (resp. Bottom) of the cell.
741   --  If Row or Col is negative, the widget is attached to the row buttons or
742   --  column buttons.
743   --  Widget will not be moved if the cell is moved.
744
745   procedure Attach_Floating
746      (Sheet    : access Gtk_Sheet_Record;
747       Widget   : access Gtk.Widget.Gtk_Widget_Record'Class;
748       Row      : Gint;
749       Col      : Gint);
750   --  Attach a child at the current location or (Row, Col).
751   --  If the cell is moved because of resizing or other reasons, Widget will
752   --  be moved as well.
753
754   procedure Move_Child
755      (Sheet  : access Gtk_Sheet_Record;
756       Widget : access Gtk.Widget.Gtk_Widget_Record'Class;
757       X      : Gint;
758       Y      : Gint);
759   --  Move a child of the table to a specific location in pixels.
760   --  A warning is printed if Widget is not already a child of Sheet.
761
762   function Get_Child_At
763     (Sheet  : access Gtk_Sheet_Record;
764      Row    : Gint;
765      Col    : Gint)
766      return Gtk_Sheet_Child;
767   --  Return the widget associated with the cell.
768
769   function Get_Widget (Child : Gtk_Sheet_Child) return Gtk.Widget.Gtk_Widget;
770   --  Return the widget in the child.
771
772   procedure Button_Attach
773     (Sheet   : access Gtk_Sheet_Record;
774      Widget  : access Gtk.Widget.Gtk_Widget_Record'Class;
775      Row     : Gint;
776      Col     : Gint);
777   --  Attach a new button in the row or column title.
778   --  One of Row or Col must be negative (but only one).
779   --  This can be used to modify the standard buttons that appear at the top
780   --  of each column, or on the left of each row.
781
782   -----------------------
783   -- Links / User_Data --
784   -----------------------
785   --  You can associate any kind of data with a cell, just like you
786   --  can associate user_data with all the widgets.
787   --  Note that this uses a generic package, which must be instantiated at
788   --  library level since it has internal clean up functions.
789
790   generic
791      --  <doc_ignore>
792      type Data_Type (<>) is private;
793   package Links is
794      type Data_Type_Access is access all Data_Type;
795      --  </doc_ignore>
796
797      procedure Link_Cell
798        (Sheet : access Gtk_Sheet_Record'Class;
799         Row   : Gint;
800         Col   : Gint;
801         Link  : Data_Type);
802      --  Associate some user specific data with a given cell.
803
804      function Get_Link
805        (Sheet  : access Gtk_Sheet_Record'Class;
806         Row    : Gint;
807         Col    : Gint)
808         return  Data_Type_Access;
809      --  Return the user data associated with the cell.
810      --  null is returned if the cell has no user data.
811
812   end Links;
813
814   procedure Remove_Link
815     (Sheet : access Gtk_Sheet_Record;
816      Row   : Gint;
817      Col   : Gint);
818   --  Delete the user data associated with the cell.
819
820   -------------
821   -- Signals --
822   -------------
823
824   --  <signals>
825   --  The following new signals are defined for this widget:
826   --
827   --  - "set_scroll_adjustments"
828   --    procedure Handler (Sheet : access Gtk_Sheet_Record'Class;
829   --                       Hadj  : Gtk_Adjustement;
830   --                       Vadj  : Gtk_Adjustment);
831   --
832   --    Emitted when the adjustments used to indicate which area of the sheet
833   --    is visible are set or changed. This is not called when their value is
834   --    changed, only when a new one is set.
835   --
836   --  - "select_row"
837   --    procedure Handler (Sheet : access Gtk_Sheet_Record'Class;
838   --                       Row   : Gint);
839   --
840   --    Emitted when a new row is selected.
841   --
842   --  - "select_column"
843   --    procedure Handler (Sheet  : access Gtk_Sheet_Record'Class;
844   --                       Column : Gint);
845   --
846   --    Emitted when a new column is selected.
847   --
848   --  - "select_range"
849   --    procedure Handler (Sheet     : access Gtk_Sheet_Record'Class;
850   --                       The_Range : Gtk_Sheet_Range);
851   --
852   --    Emitted when a new range of cells is selected.
853   --
854   --  - "clip_range"
855   --    procedure Handler (Sheet      : access Gtk_Sheet_Record'Class;
856   --                       Clip_Range : Gtk_Sheet_Range);
857   --
858   --    Emitted when the clip area is set to a new value.
859   --
860   --  - "resize_range"
861   --    procedure Handler (Sheet     : access Gtk_Sheet_Record'Class;
862   --                       Old_Range : Gtk_Sheet_Range;
863   --                       New_Range : Gtk_Sheet_Range);
864   --
865   --    Emitted when the current range of selected cell is resized (ie new
866   --    cells are added to it or removed from it).
867   --
868   --  - "move_range"
869   --    procedure Handler (Sheet     : access Gtk_Sheet_Record'Class;
870   --                       Old_Range : Gtk_Sheet_Range;
871   --                       New_Range : Gtk_Sheet_Range);
872   --
873   --    Emitted when the current range of selected cell is moved (ie the
874   --    top-left cell is changed, but the size is not modified).
875   --
876   --  - "traverse"
877   --    function Handler (Sheet      : access Gtk_Sheet_Record'Class;
878   --                      Row        : Gint;
879   --                      Column     : Gint;
880   --                      New_Row    : Gint_Access;
881   --                      New_Column : Gint_Access)
882   --                     return Boolean;
883   --
884   --    Emitted when the user wants to make a new cell active. The coordinates
885   --    of the currently active cell are passed in (Row, Column), the
886   --    coordinates of the cell that the user would like to select are
887   --    passed in (New_Row, New_Column). The callback can modify the new
888   --    values, and should return True if the new coordinates are accepted,
889   --    False if the selection should be refused.
890   --
891   --  - "deactivate"
892   --    function Handler (Sheet  : access Gtk_Sheet_Record'Class;
893   --                      Row    : Gint;
894   --                      Column : Gint)
895   --                     return Boolean;
896   --
897   --    Emitted when the user wants to deactivate a specific cell. The
898   --    callback should return True if the cell can be deactivated, False
899   --    otherwise. See the subprogram Deactivate_Cell.
900   --
901   --  - "activate"
902   --    function Handler (Sheet  : access Gtk_Sheet_Record'Class;
903   --                      Row    : Gint;
904   --                      Column : Gint)
905   --                     return Boolean;
906   --
907   --    Emitted when the user wants to activate a specific cell. The
908   --    callback should return True if the cell can be activated, False
909   --    otherwise. See the subprogram Activate_Cell.
910   --
911   --  - "set_cell"
912   --    procedure Handler (Sheet  : access Gtk_Sheet_Record'Class;
913   --                       Row    : Gint;
914   --                       Column : Gint);
915   --
916   --    Emitted from Hide_Active_Cell, when the cell is non-empty. ???
917   --
918   --  - "clear_cell"
919   --    procedure Handler (Sheet  : access Gtk_Sheet_Record'Class;
920   --                       Row    : Gint;
921   --                       Column : Gint);
922   --
923   --    Emitted when the content of the cell has been deleted (the text is
924   --    now the empty string).
925   --
926   --  - "changed"
927   --    procedure Handler (Sheet  : access Gtk_Sheet_Record'Class;
928   --                       Row    : Gint;
929   --                       Column : Gint);
930   --
931   --    Emitted when the content of the cell is modified (either the text
932   --    itself, or its properties, alignment,...)
933   --    A value of -1 for Row or Column means the row title, the column
934   --    title, or their intersection.
935   --
936   --  - "new_column_width"
937   --    procedure Handler (Sheet  : access Gtk_Sheet_Record'Class;
938   --                       Column : Gint;
939   --                       Width  : Guint);
940   --
941   --    Emitted whenever the width of the column is changed, either by the
942   --    user or automatically if the cells should automatically resize
943   --    themselves depending on their contents).
944   --
945   --  - "new_row_height"
946   --    procedure Handler (Sheet  : access Gtk_Sheet_Record'Class;
947   --                       Row    : Gint;
948   --                       Height : Guint);
949   --
950   --    Emitted whenever the height of the row is changed.
951   --  </signals>
952
953private
954   type Gtk_Sheet_Record is new Gtk.Container.Gtk_Container_Record
955     with null record;
956   type Gtk_Sheet_Child_Record is
957     new Gtk.Widget.Gtk_Widget_Record with null record;
958
959   pragma Import (C, Get_Type, "gtk_sheet_get_type");
960   pragma Import (C, Range_Get_Type, "gtk_sheet_range_get_type");
961
962   No_Border     : constant Gtk_Sheet_Border := 0;
963   Left_Border   : constant Gtk_Sheet_Border := 1;
964   Right_Border  : constant Gtk_Sheet_Border := 2;
965   Top_Border    : constant Gtk_Sheet_Border := 4;
966   Bottom_Border : constant Gtk_Sheet_Border := 8;
967   All_Borders   : constant Gtk_Sheet_Border := 15;
968   pragma Convention (C, Gtk_Sheet_Range);
969end Gtk.Extra.Sheet;
970
971--  Unbound:
972--    gtk_sheet_get_entry_widget
973--    gtk_sheet_get_attributes
974