comp.lang.ada
 help / color / mirror / Atom feed
* Gtk ada Sizes in pixels
@ 2020-07-02  5:13 ldries46
  2020-07-02 14:23 ` Dennis Lee Bieber
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: ldries46 @ 2020-07-02  5:13 UTC (permalink / raw)


I have a problem with Sizes of Gtk Windows.
On a screen of 3840 * 2160 pixels I want a Main window of about 2000 * 
1200 pixels. When I run the program where the initiation code  is herby 
given (as far a sizes are involved) it looks like a window of about 3000 
* 2000 pixels what should I do to get real pixels

in the spec:
    Mainsize_H          : Gint := 2000; -- Width of the main window
    Mainsize_V          : Gint := 1200; -- Height of the main window

from another package:

    type Screen_resolution is record
       width  : integer := 0;
       heigth : integer := 0;
    end record;


    procedure Init(MainWindow : access Main_Window_Record'Class) is
       pragma Suppress (All_Checks);
       Scr         : Screen_resolution;
       Pixmaps_Dir : constant String := "pixmaps/";
       FontDesc    : Pango_Font_Description;
    begin
       Gtk.Window.Initialize (MainWindow, Window_Toplevel);
       MainWindow.Set_Title (To_String(Lan_Window_Title(Lan)));
       Set_Position (MainWindow, Win_Pos_Center);
       Set_Modal (MainWindow, False);
       Set_Resizable (MainWindow, True);
       Scr := Resolution;
       if Scr.width < integer(Mainsize_H) and Scr.width /= 0 then
          MainSize_H := Gint(Scr.Width);
       end if;
       if Scr.heigth < integer(Mainsize_V) and Scr.heigth /= 0 then
          MainSize_V := Gint(Scr.heigth);
       end if;
       Set_Default_Size (MainWindow, Mainsize_H, Mainsize_V);
...
...
       Get_Size(MainWindow, W, H);
       --Debug
       Print(Scr.width);
       Print_Line(Scr.heigth);
       Print(integer(Mainsize_H));
       Print_Line(integer(Mainsize_V));
       Print(integer(W));
       Print_Line(integer(H));
       ----
...
...
    end Init;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Gtk ada Sizes in pixels
  2020-07-02  5:13 Gtk ada Sizes in pixels ldries46
@ 2020-07-02 14:23 ` Dennis Lee Bieber
  2020-07-02 15:54   ` ldries46
  2020-09-03 10:31 ` riya patel
  2020-09-19 14:09 ` erchetan33
  2 siblings, 1 reply; 8+ messages in thread
From: Dennis Lee Bieber @ 2020-07-02 14:23 UTC (permalink / raw)


On Thu, 2 Jul 2020 07:13:15 +0200, ldries46 <bertus.dries@planet.nl>
declaimed the following:

>I have a problem with Sizes of Gtk Windows.
>On a screen of 3840 * 2160 pixels I want a Main window of about 2000 * 
>1200 pixels. When I run the program where the initiation code  is herby 
>given (as far a sizes are involved) it looks like a window of about 3000 
>* 2000 pixels what should I do to get real pixels
>

	Isn't this essentially the same question you asked on June 23 in

Message-ID: <5ef1a1cc$0$1475$e4fe514c@news.kpn.nl>

!> I am using a high definition screen 4K (3840 * 2160 pixels) and two 
!> computers one with a graphic card which can handle this resolution and 
!> an older one which can handle up to 1920 * 1080. (the first on Windows 
!> 10 the second on Linux Ubuntu). I want both computers capable of running
!> my programs even if I define a the window on 2000 * 1200 for a Gtk 
!> project. On the computer that can handle the resolution the there is of 
!> course no problem. On the other the screen is window is to big for the 
!> resolution and is shown only partly (of course).

	If not, they are very closely related... and probably not Ada specific
(how does a C/C++ GTK experiment behave?)

https://lazka.github.io/pgi-docs/Gdk-3.0/classes/WindowAttr.html
https://lazka.github.io/pgi-docs/Gdk-3.0/classes/Geometry.html
"""
The other useful fields are the min_aspect and max_aspect fields; these
contain a width/height ratio as a floating point number. If a geometry
widget is set, the aspect applies to the geometry widget rather than the
entire window. The most common use of these hints is probably to set
min_aspect and max_aspect to the same value, thus forcing the window to
keep a constant aspect ratio.
"""

	In a quick Google -- I don't seem to find aspect exposed
http://docs.adacore.com/live/wave/gtkada/html/gtkada_rm/index.html
other than in Gtk.Aspect_Frame


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Gtk ada Sizes in pixels
  2020-07-02 14:23 ` Dennis Lee Bieber
@ 2020-07-02 15:54   ` ldries46
  2020-07-03  9:54     ` ldries46
  0 siblings, 1 reply; 8+ messages in thread
From: ldries46 @ 2020-07-02 15:54 UTC (permalink / raw)


Op 2-7-2020 om 16:23 schreef Dennis Lee Bieber:
> On Thu, 2 Jul 2020 07:13:15 +0200, ldries46 <bertus.dries@planet.nl>
> declaimed the following:
>
>> I have a problem with Sizes of Gtk Windows.
>> On a screen of 3840 * 2160 pixels I want a Main window of about 2000 *
>> 1200 pixels. When I run the program where the initiation code  is herby
>> given (as far a sizes are involved) it looks like a window of about 3000
>> * 2000 pixels what should I do to get real pixels
>>
> 	Isn't this essentially the same question you asked on June 23 in
>
> Message-ID: <5ef1a1cc$0$1475$e4fe514c@news.kpn.nl>
>
> !> I am using a high definition screen 4K (3840 * 2160 pixels) and two
> !> computers one with a graphic card which can handle this resolution and
> !> an older one which can handle up to 1920 * 1080. (the first on Windows
> !> 10 the second on Linux Ubuntu). I want both computers capable of running
> !> my programs even if I define a the window on 2000 * 1200 for a Gtk
> !> project. On the computer that can handle the resolution the there is of
> !> course no problem. On the other the screen is window is to big for the
> !> resolution and is shown only partly (of course).
>
> 	If not, they are very closely related... and probably not Ada specific
> (how does a C/C++ GTK experiment behave?)
>
> https://lazka.github.io/pgi-docs/Gdk-3.0/classes/WindowAttr.html
> https://lazka.github.io/pgi-docs/Gdk-3.0/classes/Geometry.html
> """
> The other useful fields are the min_aspect and max_aspect fields; these
> contain a width/height ratio as a floating point number. If a geometry
> widget is set, the aspect applies to the geometry widget rather than the
> entire window. The most common use of these hints is probably to set
> min_aspect and max_aspect to the same value, thus forcing the window to
> keep a constant aspect ratio.
> """
>
> 	In a quick Google -- I don't seem to find aspect exposed
> http://docs.adacore.com/live/wave/gtkada/html/gtkada_rm/index.html
> other than in Gtk.Aspect_Frame
>
>
No it is not the same question but it is in line. In the mean time from  
answers then I found first GtkWindow. Get_Size which did not gave a 
correct answer at the moment I needed it. But from there I found 
Gdk.Windows and Gdk.Screen where all interesting  functions were 
depreciated from version  and I was directed to a GdkMonitor which was 
not present in the highest version of GtkAda I could find. From that 
moment I decided to put the values in the environment variables, the 
least nice solution. It was then that I realised that the window of my 
program did not have the correct format ca about 1.5 times as big as 
expected. So this question is another than earlier but it is an 
offspring of that other question

I will investigate further

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Gtk ada Sizes in pixels
  2020-07-02 15:54   ` ldries46
@ 2020-07-03  9:54     ` ldries46
  2020-07-03 16:16       ` Dennis Lee Bieber
  0 siblings, 1 reply; 8+ messages in thread
From: ldries46 @ 2020-07-03  9:54 UTC (permalink / raw)


Op 2-7-2020 om 17:54 schreef ldries46:
> Op 2-7-2020 om 16:23 schreef Dennis Lee Bieber:
>> On Thu, 2 Jul 2020 07:13:15 +0200, ldries46 <bertus.dries@planet.nl>
>> declaimed the following:
>>
>>> I have a problem with Sizes of Gtk Windows.
>>> On a screen of 3840 * 2160 pixels I want a Main window of about 2000 *
>>> 1200 pixels. When I run the program where the initiation code is herby
>>> given (as far a sizes are involved) it looks like a window of about 
>>> 3000
>>> * 2000 pixels what should I do to get real pixels
>>>
>>     Isn't this essentially the same question you asked on June 23 in
>>
>> Message-ID: <5ef1a1cc$0$1475$e4fe514c@news.kpn.nl>
>>
>> !> I am using a high definition screen 4K (3840 * 2160 pixels) and two
>> !> computers one with a graphic card which can handle this resolution 
>> and
>> !> an older one which can handle up to 1920 * 1080. (the first on 
>> Windows
>> !> 10 the second on Linux Ubuntu). I want both computers capable of 
>> running
>> !> my programs even if I define a the window on 2000 * 1200 for a Gtk
>> !> project. On the computer that can handle the resolution the there 
>> is of
>> !> course no problem. On the other the screen is window is to big for 
>> the
>> !> resolution and is shown only partly (of course).
>>
>>     If not, they are very closely related... and probably not Ada 
>> specific
>> (how does a C/C++ GTK experiment behave?)
>>
>> https://lazka.github.io/pgi-docs/Gdk-3.0/classes/WindowAttr.html
>> https://lazka.github.io/pgi-docs/Gdk-3.0/classes/Geometry.html
>> """
>> The other useful fields are the min_aspect and max_aspect fields; these
>> contain a width/height ratio as a floating point number. If a geometry
>> widget is set, the aspect applies to the geometry widget rather than the
>> entire window. The most common use of these hints is probably to set
>> min_aspect and max_aspect to the same value, thus forcing the window to
>> keep a constant aspect ratio.
>> """
>>
>>     In a quick Google -- I don't seem to find aspect exposed
>> http://docs.adacore.com/live/wave/gtkada/html/gtkada_rm/index.html
>> other than in Gtk.Aspect_Frame
>>
>>
> No it is not the same question but it is in line. In the mean time 
> from  answers then I found first GtkWindow. Get_Size which did not 
> gave a correct answer at the moment I needed it. But from there I 
> found Gdk.Windows and Gdk.Screen where all interesting  functions were 
> depreciated from version  and I was directed to a GdkMonitor which was 
> not present in the highest version of GtkAda I could find. From that 
> moment I decided to put the values in the environment variables, the 
> least nice solution. It was then that I realised that the window of my 
> program did not have the correct format ca about 1.5 times as big as 
> expected. So this question is another than earlier but it is an 
> offspring of that other question
>
> I will investigate further
I think I found the latest trouble, now the solution for that
Gtk uses the screen size that is set in windows and not the real screen 
size. For readability on my screen I just set 175%. Now when I used 2000 
pixels the Gtk interpreted that as 3500 pixels . Maybe Gdk.Monitor could 
solve that but I cannot reach that (yet?).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Gtk ada Sizes in pixels
  2020-07-03  9:54     ` ldries46
@ 2020-07-03 16:16       ` Dennis Lee Bieber
  2020-07-05  7:24         ` ldries46
  0 siblings, 1 reply; 8+ messages in thread
From: Dennis Lee Bieber @ 2020-07-03 16:16 UTC (permalink / raw)


On Fri, 3 Jul 2020 11:54:00 +0200, ldries46 <bertus.dries@planet.nl>
declaimed the following:

>I think I found the latest trouble, now the solution for that
>Gtk uses the screen size that is set in windows and not the real screen 
>size. For readability on my screen I just set 175%. Now when I used 2000 
>pixels the Gtk interpreted that as 3500 pixels . Maybe Gdk.Monitor could 
>solve that but I cannot reach that (yet?).

	Quick Google does reveal
https://developer.gnome.org/gdk3/stable/GdkMonitor.html#gdk-monitor-get-scale-factor
https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-get-scale-factor
BUT... It's an integer... So obviously "1.75" can't be represented in it.
And the second description seems to imply that it goes the other
direction...

https://wiki.gnome.org/HowDoI/HiDpi/
https://github.com/gnunn1/tilix/issues/894


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Gtk ada Sizes in pixels
  2020-07-03 16:16       ` Dennis Lee Bieber
@ 2020-07-05  7:24         ` ldries46
  0 siblings, 0 replies; 8+ messages in thread
From: ldries46 @ 2020-07-05  7:24 UTC (permalink / raw)


Op 3-7-2020 om 18:16 schreef Dennis Lee Bieber:
> On Fri, 3 Jul 2020 11:54:00 +0200, ldries46 <bertus.dries@planet.nl>
> declaimed the following:
>
>> I think I found the latest trouble, now the solution for that
>> Gtk uses the screen size that is set in windows and not the real screen
>> size. For readability on my screen I just set 175%. Now when I used 2000
>> pixels the Gtk interpreted that as 3500 pixels . Maybe Gdk.Monitor could
>> solve that but I cannot reach that (yet?).
> 	Quick Google does reveal
> https://developer.gnome.org/gdk3/stable/GdkMonitor.html#gdk-monitor-get-scale-factor
> https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-get-scale-factor
> BUT... It's an integer... So obviously "1.75" can't be represented in it.
> And the second description seems to imply that it goes the other
> direction...
>
> https://wiki.gnome.org/HowDoI/HiDpi/
> https://github.com/gnunn1/tilix/issues/894
>
>
Thanks for your support. but indeed it it an integer. At the moment I 
solve this by Setting the value as an environment value.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Gtk ada Sizes in pixels
  2020-07-02  5:13 Gtk ada Sizes in pixels ldries46
  2020-07-02 14:23 ` Dennis Lee Bieber
@ 2020-09-03 10:31 ` riya patel
  2020-09-19 14:09 ` erchetan33
  2 siblings, 0 replies; 8+ messages in thread
From: riya patel @ 2020-09-03 10:31 UTC (permalink / raw)


On Thursday, 2 July 2020 10:44:01 UTC+5:30, ldries46  wrote:
> I have a problem with Sizes of Gtk Windows.
> On a screen of 3840 * 2160 pixels I want a Main window of about 2000 * 
> 1200 pixels. When I run the program where the initiation code  is herby 
> given (as far a sizes are involved) it looks like a window of about 3000 
> * 2000 pixels what should I do to get real pixels
> 
> in the spec:
>     Mainsize_H          : Gint := 2000; -- Width of the main window
>     Mainsize_V          : Gint := 1200; -- Height of the main window
> 
> from another package:
> 
>     type Screen_resolution is record
>        width  : integer := 0;
>        heigth : integer := 0;
>     end record;
> 
> 
>     procedure Init(MainWindow : access Main_Window_Record'Class) is
>        pragma Suppress (All_Checks);
>        Scr         : Screen_resolution;
>        Pixmaps_Dir : constant String := "pixmaps/";
>        FontDesc    : Pango_Font_Description;
>     begin
>        Gtk.Window.Initialize (MainWindow, Window_Toplevel);
>        MainWindow.Set_Title (To_String(Lan_Window_Title(Lan)));
>        Set_Position (MainWindow, Win_Pos_Center);
>        Set_Modal (MainWindow, False);
>        Set_Resizable (MainWindow, True);
>        Scr := Resolution;
>        if Scr.width < integer(Mainsize_H) and Scr.width /= 0 then
>           MainSize_H := Gint(Scr.Width);
>        end if;
>        if Scr.heigth < integer(Mainsize_V) and Scr.heigth /= 0 then
>           MainSize_V := Gint(Scr.heigth);
>        end if;
>        Set_Default_Size (MainWindow, Mainsize_H, Mainsize_V);
> ...
> ...
>        Get_Size(MainWindow, W, H);
>        --Debug
>        Print(Scr.width);
>        Print_Line(Scr.heigth);
>        Print(integer(Mainsize_H));
>        Print_Line(integer(Mainsize_V));
>        Print(integer(W));
>        Print_Line(integer(H));
>        ----
> ...
> ...
>     end Init;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Gtk ada Sizes in pixels
  2020-07-02  5:13 Gtk ada Sizes in pixels ldries46
  2020-07-02 14:23 ` Dennis Lee Bieber
  2020-09-03 10:31 ` riya patel
@ 2020-09-19 14:09 ` erchetan33
  2 siblings, 0 replies; 8+ messages in thread
From: erchetan33 @ 2020-09-19 14:09 UTC (permalink / raw)


On Thursday, July 2, 2020 at 10:44:01 AM UTC+5:30, ldries46 wrote:
> I have a problem with Sizes of Gtk Windows.
> On a screen of 3840 * 2160 pixels I want a Main window of about 2000 * 
> 1200 pixels. When I run the program where the initiation code  is herby 
> given (as far a sizes are involved) it looks like a window of about 3000 
> * 2000 pixels what should I do to get real pixels
> 
> in the spec:
>     Mainsize_H          : Gint := 2000; -- Width of the main window
>     Mainsize_V          : Gint := 1200; -- Height of the main window
> 
> from another package:
> 
>     type Screen_resolution is record
>        width  : integer := 0;
>        heigth : integer := 0;
>     end record;
> 
> 
>     procedure Init(MainWindow : access Main_Window_Record'Class) is
>        pragma Suppress (All_Checks);
>        Scr         : Screen_resolution;
>        Pixmaps_Dir : constant String := "pixmaps/";
>        FontDesc    : Pango_Font_Description;
>     begin
>        Gtk.Window.Initialize (MainWindow, Window_Toplevel);
>        MainWindow.Set_Title (To_String(Lan_Window_Title(Lan)));
>        Set_Position (MainWindow, Win_Pos_Center);
>        Set_Modal (MainWindow, False);
>        Set_Resizable (MainWindow, True);
>        Scr := Resolution;
>        if Scr.width < integer(Mainsize_H) and Scr.width /= 0 then
>           MainSize_H := Gint(Scr.Width);
>        end if;
>        if Scr.heigth < integer(Mainsize_V) and Scr.heigth /= 0 then
>           MainSize_V := Gint(Scr.heigth);
>        end if;
>        Set_Default_Size (MainWindow, Mainsize_H, Mainsize_V);
> ...
> ...
>        Get_Size(MainWindow, W, H);
>        --Debug
>        Print(Scr.width);
>        Print_Line(Scr.heigth);
>        Print(integer(Mainsize_H));
>        Print_Line(integer(Mainsize_V));
>        Print(integer(W));
>        Print_Line(integer(H));
>        ----
> ...
> ...
>     end Init;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-19 14:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02  5:13 Gtk ada Sizes in pixels ldries46
2020-07-02 14:23 ` Dennis Lee Bieber
2020-07-02 15:54   ` ldries46
2020-07-03  9:54     ` ldries46
2020-07-03 16:16       ` Dennis Lee Bieber
2020-07-05  7:24         ` ldries46
2020-09-03 10:31 ` riya patel
2020-09-19 14:09 ` erchetan33

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox