AdaCore / gtkada

Ada bindings for the GTK+ graphical library.
Other
88 stars 20 forks source link

Using Cairo with GTK #3

Closed dead-crow closed 8 years ago

dead-crow commented 8 years ago

Hi ,

I'm trying to code geometric forms with cairo and display with a gtk_window .

I created the window and a gtk_drawing_area in it .

Maybe , now the "draw" signal is needed ?

If yes , i have no idea of how to use it . I read carefully descriptions in packages , but it doesn't help me .

WITH Gtk.Main ;          USE Gtk.Main ;
WITH Gtk.Window ;        USE Gtk.Window ;
WITH Gtk.Enums ;         USE Gtk.Enums ;
WITH Gtk.Button ;        USE Gtk.Button ;
WITH Gtk.Alignment ;     USE Gtk.Alignment ;
WITH Gtk.Box ;           USE Gtk.Box ;
WITH Gtk.Gentry;         USE Gtk.Gentry;
WITH Gtk.Widget ;        USE Gtk.Widget ; 
with Gtk.Handlers;

with Gtk.Drawing_Area;  use Gtk.Drawing_Area;

PROCEDURE dessine_avec_cairo IS

-----------------------
   -- VARIABLES --    | 
----------------------------------------------------------
   win : Gtk_window ;

   Btn1, Btn2 ,Btn3  : Gtk_Button ;

   alignG, alignM ,alignD  : Gtk_Alignment ;

   Boite  : Gtk_VBox ;

   Boutons :  Gtk_HBox ;

   saisie : Gtk_Entry ;

   zone_dessin : Gtk_Drawing_Area ;

----------------------------------------------------------
--Instanciation package(s) for connexion
----------------------------------------------------------

   PACKAGE P_Callback IS NEW Gtk.Handlers.Callback(Gtk_Widget_Record);

   USE P_Callback ; 

----------------------------------------------------------
--  Handlers (or callbacks)   |
----------------------------------------------------------

   procedure Stop_Program(Emetteur : access Gtk_Widget_Record'class)
   is

      PRAGMA Unreferenced (Emetteur);

   begin

      Main_Quit;

   end Stop_Program ;

-------------------------------------------------
BEGIN

   Init ; 

----------------
   -- NEW --   |
-------------------------------------------------

   Gtk_New(zone_dessin);

   Gtk_New(win);   

   Gtk_New(saisie);

   Gtk_New(Btn1, "Bouton 1") ; 
   Gtk_New(Btn2, "Bouton 2") ; 
   Gtk_New(Btn3, "Bouton 3") ; 

   Gtk_New(alignG,0.0,1.0,1.0,1.0);
   Gtk_New(alignM,0.5,1.0,1.0,1.0);
   Gtk_New(alignD,1.0,1.0,1.0,1.0);

  Gtk_New_VBox
  (Boite, homogeneous => false, Spacing => 0) ;

  Gtk_New_HBox
  (Boutons, homogeneous => false, Spacing => 0) ;

---------------------------------
--  Add                    |
---------------------------------

   alignG.add(Btn1) ;
   alignM.add(Btn2) ;
   alignD.add(Btn3) ;

   win.Add(Boite);

------------------------------------------
--  Connect                |
------------------------------------------

Connect(Widget => win ,
          Name => "destroy" ,
            Cb => Stop_Program'access);  

------------------------------------------
--  Design Window          |
------------------------------------------

    Size
      (Drawing_Area => zone_dessin ,
       Width => 100 ,
       Height => 100);

    Pack_Start
      (In_Box => Boite ,
       Child  => zone_dessin ,
       Expand => true ,
       Fill => true );

   Pack_Start
      (In_Box => Boite ,
       Child  => saisie ,
       Expand => false );

   Pack_Start
      (In_Box => Boite , 
       Child => Boutons ,
       Expand => true ,
       Fill => true );

   Pack_Start
      (In_Box => Boutons , 
       Child => alignG ,
       Expand => true ,
       Fill => true );

   Pack_Start
      (In_Box => Boutons , 
       Child => alignM ,
       Expand => true ,
       Fill => true );

   Pack_Start
      (In_Box => Boutons , 
       Child => alignD ,
       Expand => true ,
       Fill => true );

   win.Set_Default_Size(500,500) ;   

   win.set_position(Win_Pos_Mouse) ; 

   win.set_opacity(0.7) ;

   win.Show_all ; 
   Main ; 

END dessine_avec_cairo ;
dead-crow commented 8 years ago

still up to date

setton commented 8 years ago

This forum is more intended for the developers of GtkAda than the actual users. Your question is actually a gtk+ / gdk / cairo question, you will probably have more luck on the user's forums for the libraries directly.

dead-crow commented 8 years ago

Thanks for your answer setton .

I already created a topic on a GTK forum . But because it's specific to this ADA binding , i got no answer . Plus , i think that there is minimum one person here who can help me about it .

liberforce commented 8 years ago

I saw your question on that GTK forum.

Opening issues on GtkAda is used to inform the GtkAda team of a bug in their code. If you need help on how to use some software components, you need to ask your question at the right place. Try asking on http://www.stackoverflow.com and tagging your question with the proper gtk and ada tags, I'm sure you'll have better chances of someone replying.

dead-crow commented 8 years ago

liberforce = https://stackoverflow.com/questions/34472129/use-cairo-with-gtk