* GtkAda. Printing
@ 2016-08-03 7:02 ldries46
2016-08-03 7:39 ` Dmitry A. Kazakov
0 siblings, 1 reply; 9+ messages in thread
From: ldries46 @ 2016-08-03 7:02 UTC (permalink / raw)
I have a good working procedure procedure Draw_Grid(CR : Cairo_Context);
which draws the contents of a Drawing Area.
Now I want that drawing on my printer. The examples I can find on internet
all result in problems. In one g_signal_connect is called used together with
G_CALLBACK But I have no idea which package they belong to. In another,
using Gtkada.printing they use On_Draw_Page for connecting the draw_page
event with a handler routine. In that case I use
On_Draw_Page(Print_Op, Draw_Page); here Draw_Page is the name of a routine
that overwrites the value of the routine in the package.
My version is:
procedure Draw_Page(Op : Gtk_Print_Operation_Record; Context :
Gtk_Print_Context;
Page_nr : Gint) is
CR : Cairo_Context;
begin
CR := Get_Cairo_Context (Print_CR);
Draw_Grid(CR);
end Draw_Page;
But in building the compiler gives an error on Draw_Page with the messages
for On_Draw_Page
190:07: missing argument for parameter "Slot" in call to "On_Draw_Page"
declared at gtk-print_operation.ads:769
190:20: expected an access type with designated type
"Gtk_Print_Operation_Record" defined at gtk-print_operation.ads:98
190:20: found type "Gtkada_Print_Operation" defined at
gtkada-printing.ads:104
190:20: ==> in call to "On_Draw_Page" at gtk-print_operation.ads:765
190:30: no candidate interpretations match the actuals:
190:30: context requires function call, found procedure name
190:30: ==> in call to inherited operation "On_Draw_Page" at
gtkada-printing.ads:102
With Draw_Page relaced by Draw_Page'Access it gives the same errors.
The error on 190.07 and 190.20 look like the result of the one in 190.30
because
there are two instances op On_Draw_Page one with two and one with three
parameters, I use the one with two and in other procedures and functions I
can without an error set a value of type Gtk_Print_Operation at a location
that expect Gtk_Print_Operation_Record.
What is the correct way to present the handler routine in On_Draw_Page,
because that is my preference.
L. Dries
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-03 7:02 GtkAda. Printing ldries46
@ 2016-08-03 7:39 ` Dmitry A. Kazakov
2016-08-03 10:25 ` ldries46
0 siblings, 1 reply; 9+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-03 7:39 UTC (permalink / raw)
On 2016-08-03 09:02, ldries46 wrote:
> 190:07: missing argument for parameter "Slot" in call to "On_Draw_Page"
> declared at gtk-print_operation.ads:769
> 190:20: expected an access type with designated type
> "Gtk_Print_Operation_Record" defined at gtk-print_operation.ads:98
> 190:20: found type "Gtkada_Print_Operation" defined at
> gtkada-printing.ads:104
The compiler told you everything you need. You use an instance of
Gtkada_Print_Operation instead of access Gtk_Print_Operation_Record.
The types are declared as follows:
type Gtkada_Print_Operation_Record is
new Gtk_Print_Operation_Record with private;
type Gtkada_Print_Operation is access all Gtkada_Print_Operation_Record;
P.S. Granted, it seems a glitch in the GtkAda bindings which should have
used access Gtk_Print_Operation_Record'Class instead. But nothing you
could not workaround with an explicit type conversion...
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-03 7:39 ` Dmitry A. Kazakov
@ 2016-08-03 10:25 ` ldries46
2016-08-03 10:55 ` Dmitry A. Kazakov
0 siblings, 1 reply; 9+ messages in thread
From: ldries46 @ 2016-08-03 10:25 UTC (permalink / raw)
Yes Print is declared as Gtkada_Print_Operation; and still in the Call to
routine Set_N_Pages(Print_Op, 1); the compiler does not find an error while
the declaration is
procedure Set_N_Pages
(Self : not null access Gtk_Print_Operation_Record;
N_Pages : Gint);
and
type Gtkada_Print_Operation_Record is new
Gtk_Print_Operation_Record with private;
type Gtkada_Print_Operation is access all Gtkada_Print_Operation_Record;
I expect that in the compiler to react the same in simular cases. Therefore
I think that the error in lines 190:30 is the real error and the one I asked
about.
"Dmitry A. Kazakov" schreef in bericht news:nns747$s6g$1@gioia.aioe.org...
On 2016-08-03 09:02, ldries46 wrote:
> 190:07: missing argument for parameter "Slot" in call to "On_Draw_Page"
> declared at gtk-print_operation.ads:769
> 190:20: expected an access type with designated type
> "Gtk_Print_Operation_Record" defined at gtk-print_operation.ads:98
> 190:20: found type "Gtkada_Print_Operation" defined at
> gtkada-printing.ads:104
The compiler told you everything you need. You use an instance of
Gtkada_Print_Operation instead of access Gtk_Print_Operation_Record.
The types are declared as follows:
type Gtkada_Print_Operation_Record is
new Gtk_Print_Operation_Record with private;
type Gtkada_Print_Operation is access all Gtkada_Print_Operation_Record;
P.S. Granted, it seems a glitch in the GtkAda bindings which should have
used access Gtk_Print_Operation_Record'Class instead. But nothing you
could not workaround with an explicit type conversion...
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-03 10:25 ` ldries46
@ 2016-08-03 10:55 ` Dmitry A. Kazakov
2016-08-04 5:33 ` ldries46
0 siblings, 1 reply; 9+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-03 10:55 UTC (permalink / raw)
On 2016-08-03 12:25, ldries46 wrote:
> Yes Print is declared as Gtkada_Print_Operation; and still in the Call
> to routine Set_N_Pages(Print_Op, 1); the compiler does not find an error
> while the declaration is
>
> procedure Set_N_Pages
> (Self : not null access Gtk_Print_Operation_Record;
> N_Pages : Gint);
>
> and
>
> type Gtkada_Print_Operation_Record is new
> Gtk_Print_Operation_Record with private;
> type Gtkada_Print_Operation is access all Gtkada_Print_Operation_Record;
>
> I expect that in the compiler to react the same in simular cases.
> Therefore I think that the error in lines 190:30 is the real error and
> the one I asked about.
That depends on whether the operation is primitive or type specific. A
primitive operation is inherited. Draw_Page parameter types are
access Gtk_Print_Operation_Record'Class;
not null access Gtk_Context_Record'Class;
Gint
not
Gtk_Print_Operation_Record;
Gtk_Print_Context;
Gint
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-03 10:55 ` Dmitry A. Kazakov
@ 2016-08-04 5:33 ` ldries46
2016-08-04 7:01 ` Dmitry A. Kazakov
0 siblings, 1 reply; 9+ messages in thread
From: ldries46 @ 2016-08-04 5:33 UTC (permalink / raw)
To check what you said I tried the following just added an extra
declaration:
Print_OpR : Gtkada_Print_Operation_Record;
and replaced Print_Op with it: The error stayed
Then I changed Print_OpR in On_Draw_Page with Print_OpR'Access.
The Error stayed nut said they expected Gtk_Print_Operation_record.
When I Changed the declaration accordingly The Error said they expected
Gtkada_Print_Operation_Record
This looks like an infinite loop, and again, my experience wiyh GPS ia that
somtimes the compiler tries several ways to resolve a problem abd you have
to find out which of the several Error messages is the solution for you. I
stll think It is the last one
: expected type "Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void" defined
at gtk-print_operation.ads:754
: found type access to procedure "Draw_Page" defined at line 191
: ==> in call to inherited operation "On_Draw_Page" at
gtkada-printing.ads:102
I still cannot find how to address the draw_page routine ib there
"Dmitry A. Kazakov" schreef in bericht news:nnsij4$1ddn$1@gioia.aioe.org...
On 2016-08-03 12:25, ldries46 wrote:
> Yes Print is declared as Gtkada_Print_Operation; and still in the Call
> to routine Set_N_Pages(Print_Op, 1); the compiler does not find an error
> while the declaration is
>
> procedure Set_N_Pages
> (Self : not null access Gtk_Print_Operation_Record;
> N_Pages : Gint);
>
> and
>
> type Gtkada_Print_Operation_Record is new
> Gtk_Print_Operation_Record with private;
> type Gtkada_Print_Operation is access all Gtkada_Print_Operation_Record;
>
> I expect that in the compiler to react the same in simular cases.
> Therefore I think that the error in lines 190:30 is the real error and
> the one I asked about.
That depends on whether the operation is primitive or type specific. A
primitive operation is inherited. Draw_Page parameter types are
access Gtk_Print_Operation_Record'Class;
not null access Gtk_Context_Record'Class;
Gint
not
Gtk_Print_Operation_Record;
Gtk_Print_Context;
Gint
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-04 5:33 ` ldries46
@ 2016-08-04 7:01 ` Dmitry A. Kazakov
2016-08-04 11:39 ` ldries46
0 siblings, 1 reply; 9+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-04 7:01 UTC (permalink / raw)
On 2016-08-04 07:33, ldries46 wrote:
> I still cannot find how to address the draw_page routine ib there
You must use correct types. That's all. If Draw_Page does not match
expected parameters profile wrap it into another subprogram.
GtkAda has examples (testgtk). Read the example of printing
(create_print.adb). Modify it for your case.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-04 7:01 ` Dmitry A. Kazakov
@ 2016-08-04 11:39 ` ldries46
2016-08-04 12:27 ` ldries46
0 siblings, 1 reply; 9+ messages in thread
From: ldries46 @ 2016-08-04 11:39 UTC (permalink / raw)
I tried the various files from the Gtkada examples but they use almost the
same methods I do.
The only thing I cannot find in these files is how to use On_Draw_Page and
that is the point that causes my trouble.
When outcommenting the all works correct can see the Print dialog and I even
can start the print. This print is empty, because the draw_page event is not
connected with the Draw_Page routine. To create that the On_Draw_Page
routine is necessary. And that still is creating the troubles.
The Call rouine is of the following type :
Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void. Describes as
type Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void is not null access
procedure
(Self : access Gtk_Print_Operation_Record'Class;
Context : not null access
Gtk.Print_Context.Gtk_Print_Context_Record'Class;
Page_Nr : Gint);
Until now I have tried Draw_Page and Draw_Page'Access
L. Dries
"Dmitry A. Kazakov" schreef in bericht news:nnup8m$6jg$1@gioia.aioe.org...
On 2016-08-04 07:33, ldries46 wrote:
> I still cannot find how to address the draw_page routine ib there
You must use correct types. That's all. If Draw_Page does not match
expected parameters profile wrap it into another subprogram.
GtkAda has examples (testgtk). Read the example of printing
(create_print.adb). Modify it for your case.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-04 11:39 ` ldries46
@ 2016-08-04 12:27 ` ldries46
2016-08-05 17:34 ` ldries46
0 siblings, 1 reply; 9+ messages in thread
From: ldries46 @ 2016-08-04 12:27 UTC (permalink / raw)
After looking at several places I found the following acc LRM (3.10) I must
declare a parameter of the cb.... type
Draw : Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void
:= Draw_Page'Access;
and changing On_Draw_Page to
On_Draw_Page(Print_Op, Draw);
Now the error changed to
: expected type "Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void" defined
at gtk-print_operation.ads:754
: found type access to procedure "Draw_Page" defined at line 184
"ldries46" schreef in bericht news:57a3297e$0$20642$e4fe514c@news.kpn.nl...
I tried the various files from the Gtkada examples but they use almost the
same methods I do.
The only thing I cannot find in these files is how to use On_Draw_Page and
that is the point that causes my trouble.
When outcommenting the all works correct can see the Print dialog and I even
can start the print. This print is empty, because the draw_page event is not
connected with the Draw_Page routine. To create that the On_Draw_Page
routine is necessary. And that still is creating the troubles.
The Call rouine is of the following type :
Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void. Describes as
type Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void is not null access
procedure
(Self : access Gtk_Print_Operation_Record'Class;
Context : not null access
Gtk.Print_Context.Gtk_Print_Context_Record'Class;
Page_Nr : Gint);
Until now I have tried Draw_Page and Draw_Page'Access
L. Dries
"Dmitry A. Kazakov" schreef in bericht news:nnup8m$6jg$1@gioia.aioe.org...
On 2016-08-04 07:33, ldries46 wrote:
> I still cannot find how to address the draw_page routine ib there
You must use correct types. That's all. If Draw_Page does not match
expected parameters profile wrap it into another subprogram.
GtkAda has examples (testgtk). Read the example of printing
(create_print.adb). Modify it for your case.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GtkAda. Printing
2016-08-04 12:27 ` ldries46
@ 2016-08-05 17:34 ` ldries46
0 siblings, 0 replies; 9+ messages in thread
From: ldries46 @ 2016-08-05 17:34 UTC (permalink / raw)
I got it right, The problem was in de Draw_Page Routinewhere a typing error
prevented the compiler from recognizing the routine as an callback routine.
L. Dries
"ldries46" schreef in bericht news:57a334d0$0$20655$e4fe514c@news.kpn.nl...
After looking at several places I found the following acc LRM (3.10) I must
declare a parameter of the cb.... type
Draw : Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void
:= Draw_Page'Access;
and changing On_Draw_Page to
On_Draw_Page(Print_Op, Draw);
Now the error changed to
: expected type "Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void" defined
at gtk-print_operation.ads:754
: found type access to procedure "Draw_Page" defined at line 184
"ldries46" schreef in bericht news:57a3297e$0$20642$e4fe514c@news.kpn.nl...
I tried the various files from the Gtkada examples but they use almost the
same methods I do.
The only thing I cannot find in these files is how to use On_Draw_Page and
that is the point that causes my trouble.
When outcommenting the all works correct can see the Print dialog and I even
can start the print. This print is empty, because the draw_page event is not
connected with the Draw_Page routine. To create that the On_Draw_Page
routine is necessary. And that still is creating the troubles.
The Call rouine is of the following type :
Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void. Describes as
type Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void is not null access
procedure
(Self : access Gtk_Print_Operation_Record'Class;
Context : not null access
Gtk.Print_Context.Gtk_Print_Context_Record'Class;
Page_Nr : Gint);
Until now I have tried Draw_Page and Draw_Page'Access
L. Dries
"Dmitry A. Kazakov" schreef in bericht news:nnup8m$6jg$1@gioia.aioe.org...
On 2016-08-04 07:33, ldries46 wrote:
> I still cannot find how to address the draw_page routine ib there
You must use correct types. That's all. If Draw_Page does not match
expected parameters profile wrap it into another subprogram.
GtkAda has examples (testgtk). Read the example of printing
(create_print.adb). Modify it for your case.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-08-05 17:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-03 7:02 GtkAda. Printing ldries46
2016-08-03 7:39 ` Dmitry A. Kazakov
2016-08-03 10:25 ` ldries46
2016-08-03 10:55 ` Dmitry A. Kazakov
2016-08-04 5:33 ` ldries46
2016-08-04 7:01 ` Dmitry A. Kazakov
2016-08-04 11:39 ` ldries46
2016-08-04 12:27 ` ldries46
2016-08-05 17:34 ` ldries46
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox