BBC BASIC
« Vertical text scaling »

Welcome Guest. Please Login or Register.
Jan 20th, 2018, 6:12pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Vertical text scaling  (Read 704 times)
code0
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Vertical text scaling
« Thread started on: Apr 6th, 2016, 6:48pm »

Hi, I registered to be able to write old skool interface programs mixed with graphics, I have a problem scaling vertical text rows properly in a maximized window.

Code:
      REM get screenwidth and height
      SYS "GetSystemMetrics", 0 TO screenW: SYS "GetSystemMetrics", 1 TO screenH

      REM maximize window
      SW_MAXIMIZE = 3: SYS "ShowWindow", @hwnd%, SW_MAXIMIZE

      REM reset the text viewport to fit the entire area
      VDU26

      REM user defined mode
      nCols = 80: nRows = 40: nColors = 16
      REM ================================
      menuH = 22
      REM ================================
      charW = screenW / nCols: charH = (screenH - menuH) / nRows
      VDU 23, 22, screenW; screenH; charW, charH, nColors, 128 + 8

      REM text color
      fColor = 2: bColor = 0: REM green black
      COLOUR fColor: COLOUR bColor + 128
      CLS

      FOR row = 0 TO nRows - 1
        PRINT TAB(0, row); STR$(row); :WAIT(4)
      NEXT row
      WAIT(400): CLS

      FOR col = 0 TO nCols - 1
        PRINT TAB(col, 0); RIGHT$(STR$(col), 1); :WAIT(4)
      NEXT col
      WAIT(400): CLS

      PRINT TAB(4, 10); "REM ================================";
      PRINT TAB(4, 11); "menuH = 22"
      PRINT TAB(4, 12); "REM ================================";
      PRINT TAB(4, 14); "Thanks, can you patch the code to get the true menuHeight ?"


      END
 

User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Vertical text scaling
« Reply #1 on: Apr 6th, 2016, 7:25pm »

on Apr 6th, 2016, 6:48pm, code0 wrote:
I have a problem scaling vertical text rows properly in a maximized window.

I am assuming that the variable you have called menuH is actually the height of the title bar. In that case you can calculate it as follows:

Code:
      REM get screenwidth and height
      SYS "GetSystemMetrics", 0 TO screenW: SYS "GetSystemMetrics", 1 TO screenH

      REM maximize window
      SW_MAXIMIZE = 3: SYS "ShowWindow", @hwnd%, SW_MAXIMIZE

      REM reset the text viewport to fit the entire area
      VDU26

      REM Get the dimensions of the client area:
      clientW = @vdu%!208
      clientH = @vdu%!212

      menuH = screenH - clientH 

In setting your custom mode you should use the client dimensions rather than the screen dimensions, otherwise the window won't correspond exactly to the maximized size:

Code:
      VDU 23, 22, clientW; clientH; charW, charH, nColors, 128 + 8 

Richard.
User IP Logged

code0
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Vertical text scaling
« Reply #2 on: Apr 6th, 2016, 8:20pm »

Thanks for helping me out Richard. BBC4WIN is probably the coolest tool I have seen for a long time.
« Last Edit: Apr 7th, 2016, 9:36pm by code0 » User IP Logged

code0
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Vertical text scaling
« Reply #3 on: Apr 8th, 2016, 6:23pm »

Hi, using clientH in the VDU 23, 22 statement creates a maximized window that is shifted slightly to the right/Down causing the text to both scroll up and be cut off to the right.

Using screenH instead is more what I want and text scaling seems to work ok now that I can get my menuH var, but what is going on?

Unrem/REM the last VDU 23, 22 in the code to see the difference:
Code:
      REM get screenwidth and height
      SYS "GetSystemMetrics", 0 TO screenW: SYS "GetSystemMetrics", 1 TO screenH

      REM maximize window
      SW_MAXIMIZE = 3: SYS "ShowWindow", @hwnd%, SW_MAXIMIZE
      REM reset the text viewport to fit the entire area
      VDU 26

      REM get the client area dimensions
      clientW = @vdu%!208: clientH = @vdu%!212

      REM get the menu height
      menuH = INT(screenH - clientH)

      REM user defined mode
      nCols = 64: nRows = 32: nColors = 16
      charW = INT(screenW / nCols): charH = INT((screenH - menuH) / nRows)

      REM
      VDU 23, 22, screenW; screenH; charW, charH, nColors, 128 + 8
      REM UNREM the next line, and the window position changes:
      REM VDU 23, 22, screenW; clientH; charW, charH, nColors, 128 + 8

      REM text color
      fColor = 2: bColor = 0: REM green black
      COLOUR fColor: COLOUR bColor + 128
      CLS

      FOR row = 0 TO nRows - 1
        PRINT TAB(0, row); STR$(row); :WAIT(2)
      NEXT row
      WAIT(200)

      FOR col = 0 TO nCols - 1
        PRINT TAB(col, 0); RIGHT$(STR$(col), 1); :WAIT(2)
      NEXT col
      WAIT(200)

      PRINT TAB(3, 8); "sW/sH = " + STR$(screenW) + "/" + STR$(screenH);
      PRINT TAB(3, 9); "cW/cH = " + STR$(clientW) + "/" + STR$(clientH);
      PRINT TAB(3, 10); "dY    = " + STR$(screenH - clientH)
      PRINT TAB(3, 11); "menuH = "  + STR$(menuH);
      PRINT TAB(3, 12); "Unrem last VDU 23, 22, run again, window position problem";
      PRINT TAB(3, 13);

      END
 
« Last Edit: Apr 8th, 2016, 6:40pm by code0 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Vertical text scaling
« Reply #4 on: Apr 8th, 2016, 7:08pm »

on Apr 8th, 2016, 6:23pm, code0 wrote:
what is going on?

I can't see anything wrong on my PC (Windows 10, 1920 x 1080 native resolution).

But you shouldn't necessarily expect the window you get from the VDU 22,23 to be identical to a maximized window. A maximized window is a special state, it is not the same thing as a window that happens to be the same size as the screen.

So what are you actually trying to achieve? Do you want a maximized window, a full-screen window, or a window that is the same size as the screen? Each of those options will require different code.

Richard.
User IP Logged

code0
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Vertical text scaling
« Reply #5 on: Apr 8th, 2016, 8:12pm »

Hi, I need to ask this first, did you run the the demo, then unremed the last line below, and nothing changed?

Code:
VDU 23, 22, screenW; screenH; charW, charH, nColors, 128 + 8
REM UNREM the next line, and the window position changes:
REM VDU 23, 22, screenW; clientH; charW, charH, nColors, 128 + 8 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Vertical text scaling
« Reply #6 on: Apr 8th, 2016, 9:16pm »

on Apr 8th, 2016, 8:12pm, code0 wrote:
Hi, I need to ask this first, did you run the the demo, then unremed the last line below, and nothing changed?

That's correct. I've subsequently done another test: running the two different versions of the program (one with the second VDU 23,22 commented out and the other not) in separate instances of BB4W, and then switching between the two resulting windows. There is no visible difference at all here, they are identical.

Richard.
User IP Logged

code0
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Vertical text scaling
« Reply #7 on: Apr 8th, 2016, 9:28pm »

Off ;-) How is the window on Your screen then? Which of the two Versions I described do you see in both cases?

Big edit:
in separate instances of BB4W.. What, run them in the same instance of BBC4WIN, edit the code, run again..
« Last Edit: Apr 8th, 2016, 9:34pm by code0 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Vertical text scaling
« Reply #8 on: Apr 9th, 2016, 09:16am »

on Apr 8th, 2016, 9:28pm, code0 wrote:
Which of the two Versions I described do you see in both cases?

It's hard to say. To be sure about that I would have to compare them with a simple maximized window, i.e. without the VDU 23,22. Certainly no text was 'cut off' but that doesn't really prove anything because, since the character width and height are necessarily rounded down to the next pixel, there will be a different 'margin' on the right and at the bottom depending on how the window dimensions happen to divide down.

The point I would want to reiterate is that if you specify the screen dimensions in the VDU 23,22 command you are asking Windows to do something 'impossible', i.e. to make the window bigger than the screen. If you specify the client dimensions you are asking Windows to do something which is allowed. But, as I said before, because a maximized window is a special case you can't assume that you can achieve it using VDU 23,22.

What you are trying to do is inherently tricky because of all the options Windows provides. For example you are probably assuming that the taskbar is at the bottom, but it might not be. Some people prefer the taskbar to be at the top, and some even prefer a vertical taskbar at the side! Settings such as whether the taskbar is 'locked' or not might also come into play.

It is much easier and safer to work in a conventional window, i.e. one significantly smaller than the screen. That offers all sorts of advantages: you can share the desktop with other programs (which after all is the whole point of Windows - the clue is in the name!). Your window can be the same size irrespective of the user's screen size (if you choose something small enough, like 800x600). And your program doesn't need to adapt to uncommon situations such as the taskbar being at the top, or an application sidebar using up some of the desktop.

Quote:
What, run them in the same instance of BBC4WIN, edit the code, run again..

I don't remember exactly what I did (I suspect I relied on the 'automatic backup' feature of BB4W to open your program in the second instance without having to save it first). But if your program is already saved you can just open it in two instances of BB4W and then edit one but not the other.

Richard.
User IP Logged

code0
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Vertical text scaling
« Reply #9 on: Apr 9th, 2016, 6:49pm »

Hi, thanks for looking into this. My window is a simple maximized window: SW_MAXIMIZE = 3: SYS "ShowWindow", @hwnd%, SW_MAXIMIZE
Next is VDU 26 to reset the viewports, then the VDU 23, 22 to create a custom MODE. I'm New to this Language, so I might have missed something here smiley.
What I see after the first VDU is a window With a title bar, the taskbar at the bottom, and no borders, so in this window, screenW is the same as clientW.
This is what I want, to make the program look like an old skool program, but in a window that is as big as possible.
And if People like to drag their traskbar all around the place, they can download software from someone else ;-)
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Vertical text scaling
« Reply #10 on: Apr 9th, 2016, 8:29pm »

on Apr 9th, 2016, 6:49pm, code0 wrote:
This is what I want, to make the program look like an old skool program, but in a window that is as big as possible.

"Old school" programs don't have a title bar, and they don't have a taskbar - they weren't invented back then! Surely, therefore, it would make more sense to use a full screen window? It would look more 'genuine' and at the same time it would solve the problems that you have been facing.

Quote:
And if People like to drag their traskbar all around the place, they can download software from someone else ;-)

If there isn't a (visible) taskbar then it makes no difference where they drag it! Listed below is a version of your program using a full screen window.

Richard.

Code:
      REM Get screen width and height:
      SYS "GetSystemMetrics", 0 TO screenW: SYS "GetSystemMetrics", 1 TO screenH

      REM user defined mode:
      nCols = 64: nRows = 32: nColors = 16
      charW = screenW DIV nCols : charH = screenH DIV nRows
      VDU 23, 22, screenW; screenH; charW, charH, nColors, 128 + 8

      REM Set full screen window (code from BB4W Help manual):
      GWL_STYLE = -16
      HWND_TOPMOST = -1
      WS_VISIBLE = &10000000
      WS_CLIPCHILDREN = &2000000
      WS_CLIPSIBLINGS = &4000000
      SYS "SetWindowLong", @hwnd%, GWL_STYLE, WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS
      SYS "SetWindowPos", @hwnd%, HWND_TOPMOST, 0, 0, screenW, screenH, 0
      VDU 26

      REM text color:
      fColor = 2 : bColor = 0: REM green on black
      COLOUR fColor: COLOUR bColor + 128
      CLS

      FOR row = 0 TO nRows - 1
        PRINT TAB(0, row); STR$(row); : WAIT 2
      NEXT row
      WAIT 200

      FOR col = 0 TO nCols - 1
        PRINT TAB(col, 0); RIGHT$(STR$(col), 1); : WAIT 2
      NEXT col
      WAIT 200

      PRINT TAB(nCols DIV 2 - 7, nRows DIV 2) "Alt+F4 to exit"
      REPEAT WAIT 10 : UNTIL FALSE 

« Last Edit: Apr 9th, 2016, 9:06pm by Richard Russell » User IP Logged

code0
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Vertical text scaling
« Reply #11 on: Apr 10th, 2016, 01:24am »

Thanks smiley smiley
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls