[Gambas-user] Print Dialog following the Printer.Configure - Method

T Lee Davidson t.lee.davidson at gmail.com
Thu Dec 21 19:28:23 CET 2023


On 12/21/23 10:49, T Lee Davidson wrote:
> On 12/21/23 05:59, Claus Dietrich wrote:
>> Hi Lee
>> I think, that there is a misunderstanding. I fully believe that the dialog works in other applications. I only wanted
>> to explain, that it doesn't in conjunction with the Gambas Printer class.
>> Using the Printer dialog in Gambas doesn't mean, that it takes care of all print formatting. The formatting of pages
>> including its separation and margins has to be done by Gambas code in the event handlers of the Printer class.
>> In other words: If you want to consider the settings of the print dialog - like margins - , you have know what
>> margins have been set in the print dialog. But there is no interface between the print dialog and the Gambas
>> Printer class for this.
>> Correct me if I am wrong, but this is my present experience in a demo project for the Printer class.
>> Best regards
>> Claus
> 
> You are right, Claus. There is (was) a misunderstanding. It was a misunderstanding (actually a gross ignorance) on my part of 
> how the printer configure dialog actually works. My apologies.
> 
> I tried the Printing example in the source code at /app/examples/Printing/. And, with Qt5 (I did not try with GTK), margin 
> settings are NOT respected.

This printer configure dialog issue looks like quite a mess. This:
[code]
   Debug "Device Resolution:" & Paint.Device.Resolution
   Debug "Paint width: " & Paint.Width
   Debug Subst("Resolution: X=&1, Y=&2", Paint.ResolutionX, Paint.ResolutionY)
   Debug "PaperWidth: " & prtText.PaperWidth
   Debug "print margin: " & PRINT_MARGIN
   With hExtents
     Debug Subst("hExtents: W=&1, H=&2, X=&3, X2=&4, Y=&5, Y2=&6", .W, .H, .X, .X2, .Y, .Y2)
   End With
[/code]

inserted into the Printer_Begin() event handler, of the Gambas source code Printer example, yields the following no matter what 
print device is selected (printer or file) in the printer configure dialog:

With GTK3:
FMain.prtText_Begin.104: Device Resolution: 300
FMain.prtText_Begin.105: Paint width: 595.275590551181
FMain.prtText_Begin.106: Resolution: X=72, Y=72
FMain.prtText_Begin.107: PaperWidth: 210
FMain.prtText_Begin.108: print margin: 28.3464566929134
FMain.prtText_Begin.110: hExtents: W=152, H=398, X=0, X2=152, Y=-6, Y2=392

(The Paint resolution isn't even close to the Device resolution.)

With Qt5:
FMain.prtText_Begin.104: Device Resolution: 1200
FMain.prtText_Begin.105: Paint width: 9917
FMain.prtText_Begin.106: Resolution: X=1200, Y=1200
FMain.prtText_Begin.107: PaperWidth: 210
FMain.prtText_Begin.108: print margin: 472.238095238095
FMain.prtText_Begin.110: hExtents: W=4218, H=8704, X=0, X2=4218, Y=-90, Y2=8614

I agree that the GTK dialog, being non-/dis-funcitonal, is virtually useless. I find no way whatsoever to change the margins in 
that dialog. And, it provides a third, "Preview", button for which Printer.Configure() cannot provide since it returns a boolean.

In that example, the print margin is calculated based on the ratio of Printer.PaperWidth to Paint.Width. It seems that 
calculation cannot use any margin properties as I find no Margin (or even PrintWidth or similar) property in Printer. Having 
something like that might make Printer.Configure() more useful. But, I don't know if that is even possible especially given that 
the GTK dialog wouldn't provide any margin settings at all AFAICT.

Maybe someday someone will create a GUI toolkit that does everything right. :-\


-- 
Lee



More information about the User mailing list