From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,STOX_REPLY_TYPE, STOX_REPLY_TYPE_WITHOUT_QUOTES,XPRIO autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!news.redatomik.org!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!nzpost2.xs4all.net!news.kpn.nl!not-for-mail From: "ldries46" Newsgroups: comp.lang.ada Subject: Gtk Printing programming problem a one page file does not print Date: Fri, 23 Nov 2018 10:55:50 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 Message-ID: <5bf7cea8$0$25694$e4fe514c@news.kpn.nl> NNTP-Posting-Host: 1e471046.news.kpn.nl X-Trace: G=eEDnGMLg,C=U2FsdGVkX1/l9yRe3jauTkO9nTzaaniHqVp5SmME9c1cMT/+e+KOq9/K1qFg+KNKC67n2+a+JzlYS2FFDBk3Qv52bnLpPYDS98jupT2SQ9s= X-Complaints-To: abuse@kpn.nl Xref: reader01.eternal-september.org comp.lang.ada:54877 Date: 2018-11-23T10:55:50+01:00 List-Id: I have a problem with printing from Gtk. The print is working correctly if I print a document which results in 19 pages. But with one page with 48 lines of text I just get an empty page and I just don't get the print dialog. Herewith I give you the part of the program where it goes wrong.: In the On_Print procedure: last_line := integer(nr) - 1; Print_Op := new Gtkada_Print_Operation_Record; Gtkada.Printing.Initialize (Print_Op); Gtk_New(Print_Set); Set_Current_Page (Print_Op, 1); Number := long_float(last_line) / long_float(delta_lines); Number := long_float'Rounding(Number + 0.4999999); nr_Pages := Gint(Number); Set_N_Pages (Print_Op, nr_Pages); Set_Use_Full_Page(Print_Op, true); Set_Unit (Print_Op, points); Print_Op.Set_Print_Settings(Print_Set); -------------------------------------------------------------------- -- procedure On_Draw_Page -- (Self : not null access Gtk_Print_Operation_Record; -- Call : Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void; -- After : Boolean := False); -------------------------------------------------------------------- On_Draw_Page(Print_Op, Draw); Result := Connect_and_Run(Print_Op ,Action_Print_Dialog, Main_Window); Draw is declared as Draw : Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void := Draw_Page'Access; and the Draw_Page procedure procedure Draw_Page (Op : access Gtk_Print_Operation_Record'Class; Context : not null access Gtk_Print_Context_Record'Class; Page_Number : Gint) is Cr : Cairo_Context; nr : integer; width : integer; rb : boolean; -- re : boolean; ok : boolean; str : Unbounded_String; begin nr := first_line; Cr := Get_Cairo_Context (Context); Set_Source_Rgb (Cr, 0.0, 0.0, 0.0); Select_font_face(Cr, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); Set_Font_Size(Cr, GDouble(9)); if nr = 1 then pagenr := 1; else pagenr := pagenr + 1; end if; if pagenr rem 2 = 1 then width := 70; else width := 40; end if; if last_page_line > last_line then last_page_line := last_line; end if; ok := false; while not ok loop Get_Iter_At_Line(Main_Window.Draw_Buffer, first, Gint(nr)); Get_Iter_At_Line_Offset(Main_Window.Draw_Buffer, endln, Gint(nr), 500); move_to(cr, Gdouble(width), Gdouble((nr - first_line + 1) * 13 + 65)); str := To_Unbounded_String(Get_Text(Main_Window.Draw_Buffer,first,endln)); show_text(cr, To_String(str)); nr := nr + 1; ok := nr >= last_page_line; if nr <= last_line then Forward_Line(first, rb); end if; end loop; first_line := nr - 1; last_page_line := last_page_line + delta_lines; end Draw_Page;