April 26, 2024, 08:59:25 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Amateur Radio - Callsign Display

Started by GWS, October 10, 2007, 03:44:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

I've updated a program I wrote a while ago using Creative Basic.  This is a much larger project than normal for me, but it does show that CBasic can be used for quite substantial applications. :)

I've increased the number of co-ordinates describing Countries, so the maps now appear more active when clicked on. Perhaps Europe could do with a little more work, but it's not too bad, and I got fed up poring over map locations.

This version also attempts to adjust the display to whatever screen resolution is in use.
I haven't been able to try it out at all resolutions, but it appears to work OK.

The program asks for your location when first started.  You can look up your grid co-ordinates from a map.  Once you've entered the longitude and latitude the values are stored in a file 'global.ini' in the default startup directory where you unzip all the files.

I've left my own location in there so you can just try the program.  If you wish to set it up to your own location, simply delete the existing 'global.ini' file, and enter your own location details when you next start the program.

All the files together exceeded the upload limit, so I've had to split them into two zipped files.  Just unzip both into the same directory - all the files reside in just the one directory that you choose.

Here's the first zip file ..

best wishes, :)

Graham
Tomorrow may be too late ..

GWS

.. and here's the other zip file.  Just unzip it into the same directory as the first ..

regards, :)

Graham
Tomorrow may be too late ..

Doc

Hello Graham,

Whew! ....there is no question that you put a lot of work into that little jewel. Very nice stuff and now I have plenty of new code to dig into, to see what makes it tick.  8)

Makes me wish I had pursued becoming an Amateur years ago when I still had the time for it.

QuoteThis version also attempts to adjust the display to whatever screen resolution is in use.
I haven't been able to try it out at all resolutions, but it appears to work OK.

I'm running 1024x768 here on the laptop and it picked it up just fine. For those like myself who don't have the "auto-hide" feature set on our task-bar will have to do some adjustments to compensate, but it scales perfectly.

Thanks for letting us have a look, kind sir. :)

-Doc-

Haim

Hi,
Very impressive piece of work!
Tested it and it worked perfectly on both 1400 X 1050 and 1024 X 768 screen rsolutions.
Thanks for sharing this.

Haim

GWS

Glad you like it chaps ..  :)  it was a bit hard on the brain cells, and gathering all the data was a bit wearing.

Still, if anyone else needs to use world co-ordinates for some other application, the values are all there in the 'prefix.txt' file.
Countries, regions, and exotic islands. ::)

I forgot to explain about the screen resolution scaling method .. here we go ..

Just a few notes on the problem of varying screen resolution.

If you design a program with some chosen window size, that looks OK at your current screen resolution, things may look very different on another machine which uses some other screen resolution.

As screen resolution increases, the size of your program window decreases and becomes harder to read.

So how to counteract this effect?

First check what size of screen you are running on ..

' determine current screen size ...
getscreensize varW,varH

Then set your window to look as you want it using:

' window height size multiplier ..
sm = 1.0
' set window height ...
wH = varH * sm
' set window width for 1.333 aspect ratio (ie. not widescreen) ..
wW = 1.3333 * wH

Several things here .. the size multiplier simply lets you adjust the window size to the best size for your purpose.  This then sets the window height.

Window width is here fixed at 1.33 times the height.  There is a problem with widescreen monitors because their inbuilt controller adjusts images, games, and other software display to fit the widescreen.  Consequently, a circle designed at the normal 4:3 ratio will look like an ellipse.  I found this so annoying I gave my widescreen monitor away and bought an 'old fashioned' CRT monitor.  Now I get undistorted pictures again!

I haven't tried whether the simple ruse of using 1.33 times the height actually works on a widescreen monitor - maybe the controller will still stretch the window horizontally.  If it does, there will probably be some inaccuracy with co-ordinates, since the program relies heavily on detecting the mouse position on the globe.

Now we have set the window size, we create the window:

' create main display window ...
window w2,-varW,0,wW,wH,@MINBOX,0,"GlobalView",win2

Why the '-varW' ? .. that's to create the window off-screen to the right, so that any flashing is not shown on screen.  We can later do a 'centerwindow' to place it back on screen.

Now we have a resizing window, what about the controls?

The trick is to think in terms of proportions rather than absolute pixel size.
So for a button we can use:

' set button size as proportion of window size ..
bW = 0.1 * wW
bH = 0.05 * wH

The same principal applies to all other controls, and to their position relative to the window left side and top.

Here's an example of a button control using the scaling method:

control w2,"B, Show, 0.763*wW, 0.79*wH, 0.05*wW, 0.04*wH, @ctlbtnflat, 3"



Then there is the Font problem.  Text tends to look a bit funny if you don't scale it right - I found a direct scaling didn't look quite right strangely enough.

So I used:

' set font size relative to that for an 800x600 window ..
fm = (wH / 600) ^ 0.9

That is, fonts are scaled relative to the lowest screen resolution 800x600 (I figure nobody is going to be using 640x480 anymore).  The font multiplier is adjusted slightly logarithmically using the 0.9 factor.  This seems to look OK as the screen resolution increases.

To use a font scaled in this way we get for example:

setfont w1, "Arial", 24*fm , 700/fm ,0

which sets both the font size and it's 'boldness' to keep a reaonable image balance.


Well that's more or less it.  Using screen proportions just takes a little more concentration than using absolute values ..



all the best, :)


Graham


Tomorrow may be too late ..

Egil

Thanks for sharing the nice piece of code!

If you dont mind that the program window dont cover the whole screen, you can modify the window scaling part like this:

Quote
' determine current screen size ...
getscreensize varW,varH

' window height size multiplier ..
sm = .96
' set window height ...
wH = varH * sm
' set window width for 1.333 aspect ratio (ie. not widescreen) ..
wW = varW * sm
' set the World image size ..
ims = wH * 0.85

With this modification your program looks the same, whatever screen resolution. ButI haven't been able to figure out how to change the home location yet...

This was fun!

73' de LA2PJ
Support Amateur Radio  -  Have a ham  for dinner!

Egil

Graham,
just figured out how to set my own position! I had to delete the ini-fine that came with your archive.
Support Amateur Radio  -  Have a ham  for dinner!

GWS

October 11, 2007, 10:54:56 AM #7 Last Edit: October 11, 2007, 10:59:50 AM by GWS
Yep ..  :) that's all it needs .. just delete 'global.ini', and when you re-start the program it asks for your location and creates a new global.ini file ..

Ah .. I see where you are now Egil .. in the snowy bit up North a ways ..  ;D

best wishes,  :)

Graham G4EVW
Tomorrow may be too late ..