[Gambas-user] Strange way of working about form dimensions

Benoit Minisini gambas at ...1...
Fri May 26 17:53:54 CEST 2006


On Friday 26 May 2006 17:37, ron wrote:
> ----8<---
>
> > The desktop resolution isn't the only problem. I'm practically going
> > mad here trying to make an app that works in at least the 3 main
> > resolutions (640x480, 800x600 and 1024x768). First I tried fitting the
> > window to the desktop, but that caused untold resizing problems,
> > specially with fonts and buttons. Then i decided to work with a fixed
> > 640x480 size window (size set in startup code, to avoid the same
> > problem as Leonardo), centered in the display at larger resolutions.
> > When the resolution is 640x480, I remove the window borders in code.
> > This seemed to be working more or less, though I did have to implement
> > scrollbars in the TexLlabels, as the font doesn't fit at the 2 lower
> > resolutions. Now I just found out that if I use an external monitor
> > instead of the notebook's LCD (both set at the same resolution, mind
> > you), fonts and buttons look much larger in the monitor and now a lot
> > of stuff doesn't fit in the window anymore! I'm guessing it's
> > something to do with the dpi setting that probably differs between LCD
> > and monitor, but I don't understand why, as both are set to 1024x768
> > and even the horizontal size is very similar.
> >
> > Regards,
> > Joe1962
>
> I feel your madness here in Holland :) What about me?
>
> I'm making a project that should work on a monitor 90' turned, AKA
> portrait. Resolution landscape 1280x1024 but portrait 1024x1280
>
> In the upper 1024x768 the project window and the lower part
> 1024x512 some lookup information for the user. :) (me?)
>
> I found in source code MAIN_SCALE=fm.height()/2 and initial a MAIN_SCALE=8
> fm is here the font_metrics and asumed as 8x16 ?
> I must/want use a 8x12 font.
>
> During MoveScaled X, Y, W and H are multiplied by same MAIN_SCALE.
>

I wanted forms to be scaled relatively to the height of the default font (not 
width, because it depends on the font character). The goal is having forms 
visible whatever the user font size is.

But it isn't finished. I want it to be optional at a window level. I will add 
something like a 'Scale' property to the Window class to tell if dimensions 
must be scaled or not. For example, windows don't have to be scaled when they 
are resizable and correctly managed by the program. But dialogs often must be 
scaled.

> I believe MAIN_SCALE should be "(fm.width()/fm.height()) x fm.width()"
> in the first place. But should it not be more correct to use
> "(screen.width()/screen.height()) x screen.width()" as that is the
> intension ? 

??

> The character dimensions are in no way related to the screen 
> dimensions for width/height values.
>
> The idea behind it is not bad but it works out not always to be a wanted
> side effect. Now I understand the form size problems between the to
> machines/monitor I'm using.
>
> Could it not be made a option for the project in gb.Application or
> gb.qt.Desktop to use xxxScaled or not ?

Yes.

>
> When I use MyForm.Height = MyForm.Width * DeskTop.Scale there is now
> something wrong with the height :(

???? You didn't undestand what MAIN_Scale is. Look at the source code of the 
MoveScaled and ResizeScaled methods.

>
> I thought [object].Width * DeskTop.Scale = [object].Height
>
>
> My 2 x DeskTop.Scale Cents
>
> Ron
>
>
>
> PS
> For Joe1962:
> As I asume the Fontmetrics are used as reference I asume a 8x16 font is
> used as default metrics.
>
> You can try in gb.qt/src/main.cpp at line 117:
> int MAIN_in_wait = 0;
> int MAIN_loop_level = 0;
> int MAIN_scale = 8; //<---- Change this to MAIN_scale = 16; (the height)

This default value is never used, so you can put what you want there.

>
> static bool in_event_loop = false;
>
>
> and at line 366:
>
> void MAIN_update_scale(void)
> {
> 	QFontMetrics fm(QApplication::font());
>   MAIN_scale = fm.height() / 2; // <--- change this to fm.height() / 1;
> }
>
> This should effective disable the xxxScale but I have not tested this.
> Do not forget the "make; make install"

Of course not, you just scale things twice!

You can't disable scale at the moment, unless assigning a fixed value to 
MAIN_scale. But it won't solve everything, as the IDE already uses the 
scaling process, i.e. instead of saving absolute coordinates, it saves 
absolutes coordinates divided by the current scale (see the IDE source code).

-- 
Benoit Minisini





More information about the User mailing list