LB Booster
IDE and Compiler >> Compiler >> BBC Basic for MAC
http://lbb.conforums.com/index.cgi?board=compiler&action=display&num=1471032430

BBC Basic for MAC
Post by CryptoMan on Aug 12th, 2016, 8:07pm

Is it possible to make a subset of LBB with BBC Basic for MAC?

Obviously, we depend on a lot WIN32 and KERNEL based API calls and various DLLs such as WINSOCK32, WMLIBERTY, etc which makes 100% or even 90% compatible to LBB for WINDOWS virtually impossible.

So, I think, it would be great to go back to basics and have a pretty decent LBB compatible LBB4MAC by simply adding the basic GUI elements such as NOTICE, PROMPT, FILEDIALOG, BUTTON, TEXTBOX, TEXTEDITOR, RADIOBUTTON, CHECKBOX, MENU, etc and without any stylebits or such frills using GUI library such as Qt or X-Windows or whatever.

Besides this, probably it will not be too hard to provide WINSOCK
and SQL drivers and arbitrary precision math libraries.

However, even with the basic GUI elements, it will be a good start.

As far as I have seen it, BBC for Macintosh is pretty amazing work. Congradulations. With all the graphics and sound capabilities, etc, it must have been a significant development effort.

CryptoMan
Re: BBC Basic for MAC
Post by Richard Russell on Aug 13th, 2016, 2:09pm

on Aug 12th, 2016, 8:07pm, CryptoMan wrote:
I think, it would be great to go back to basics and have a pretty decent LBB compatible LBB4MAC by simply adding the basic GUI elements such as NOTICE, PROMPT, FILEDIALOG, BUTTON, TEXTBOX, TEXTEDITOR, RADIOBUTTON, CHECKBOX, MENU, etc and without any stylebits or such frills using GUI library such as Qt or X-Windows or whatever.

You have tried BBC BASIC for Mac OS so you have already seen my attempt to emulate some of these GUI elements using plain BBC BASIC graphics. Are they functional enough for your purposes?

One major limitation of the simplistic approach I have adopted is that windows and dialog boxes are all modal and not movable. I suspect that would be unacceptable in many situations.

Carl has, I think, already gone much further in the alpha versions of LB5. So I doubt that there would be much interest in a Mac version of LBB based on what I have done for BBC BASIC. But I would be interested in other people's opinions.

Richard.

Re: BBC Basic for MAC
Post by CryptoMan on Aug 15th, 2016, 5:39pm

Yes, I have seen the FileDialog which gives the idea but requires some fine tuning.

What I meant was the standard GUI elements like LBB.

Don't we have a similar DLL like escape mechanism to MacOsX like the Win32 or Kernel functions on Macintosh?

Or, can you point to a 3rd party DLL supplier for a GUI which is callable from within BBC4MAC?

It must be hard if we look at Adobe Lightroom and Photoshop. I believe they made their own rudimentary GUI in C / C++ to make cross platform with the same look and feel.

I also thought of making a homemade GUI with BBC Basic graphics and maybe I can experiment with that if and when I can find some free time.

Anyway, I think, BBC4MAC is quite awesome.

Thanks....


Re: BBC Basic for MAC
Post by CryptoMan on Aug 15th, 2016, 5:46pm

I just got another idea.

Is it possible to add a Web Browser Control into BBC4MAC?

If that's possible maybe GUI maybe built with HTML or so much the better HTML5.

Have you seen NSBASIC?

It's been around for a long time since Palm Pilots and first Windows CEs with a dialect of Basic and the latest incarnation is I believed based on JavaScript and HTML5.

Would this give some ideas?

Probably, there are various open source Mozilla variants or better should be available.
Re: BBC Basic for MAC
Post by Mystic on Aug 16th, 2016, 2:07pm

I didn't know there was a BBC4MAC (guess what I'm doing after I type this? smiley

Mac is my main machine, and would LOVE to see more development along the BASIC arena for MAC.

One thing that has started to annoy me, is how simple HTML is for making navigable screens for a user interface, and what a pain it is to do the same thing in LBB/LB.

Don't get me wrong, I realize they are two different animals, but I would really like to see something like an HTML type of system as an interface for my BASIC programs.

Things like making links using "a href" open and closing windows easily in a browser type system, etc...

a BASIC that can do browser type windows for color, navigation and layout would be awesome!

Sorry, I think I spun off into a different direction. smiley
Re: BBC Basic for MAC
Post by Richard Russell on Aug 16th, 2016, 5:36pm

on Aug 16th, 2016, 2:07pm, Mystic wrote:
a BASIC that can do browser type windows for color, navigation and layout would be awesome!

Using ATL (Active Template Library) you can certainly have HTML windows in LB/LBB. For example this, adapted from one of Alyce's programs, illustrates color and layout achieved that way:

Code:
    nomainwin
 
    WindowWidth=400
    WindowHeight=300
    menu #main, "&File","E&xit", [quit]
 
    graphicbox #main.g, 0, 0, 100, 100
 
    open "Liberty Basic ATL Demo" For Window_nf As #main
    #main "TrapClose [quit]"
 
    Open "atl" For DLL As #atl
    CallDLL #atl, "AtlAxWinInit", Ret As long
 
    hWndViewer = hWnd(#main.g) 'Windows handle of graphicbox
    hMain = hWnd(#main)        'Windows handle of main window
 
    STRUCT Rect,_ 'struct for storing client area rectangle
        leftX as long,_     'upper left x
        upperY as long,_    'upper left y
        rightX as long,_    'lower right x
        lowerY as long      'lower right y
 
    calldll #user32,"GetClientRect",_
        hMain as ulong,_ 'window handle
        Rect as struct,_ 'name of struct
        r as long        'return
    cw = Rect.rightX.struct
    ch = Rect.lowerY.struct
 
    'resize graphicbox to fill client area of window
    #main.g "locate 0 0 ";cw+2;" ";ch+2
    #main "refresh"
 
    CallDLL #user32, "GetWindowLongA", _
        hWndViewer As ulong, _      'handle of graphicbox
        _GWL_HINSTANCE As long, _   'flag to get instance handle
        hInst As ulong              'returns instance handle of graphicbox
 
    style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL
 
    'a minimal HTML document:
    html$ = "MSHTML:<html><head></head><body>" + _
            "This is an <font color=red>HTML</font> window!" + _
            "<p><center>This line is centered</center>" + _
            "</body></html>"
            
    CallDLL #user32, "CreateWindowExA", _
        _WS_EX_STATICEDGE As long, _    'extended type
        "AtlAxWin" As ptr, _            'class name
        html$ As ptr, _                 'URL, or progID or CLSID
        style As long, _                'window style
        0 As long, _                    'left x pos
        0 As long, _                    'top y pos
        cw As long, _                   'width
        ch As long, _                   'height
        hWndViewer As ulong, _          'handle of parent = graphicbox
        100 As long, _                  'handle to menu or child window ID
        hInst As ulong, _               'parent instance handle
        0 As long, _                    'window creation data
        hATL As ulong                   'handle of active template library control
    wait
 
[quit]
    Close #main
    close #atl    'close DLL after closing window
    end 

As far as navigation is concerned you can include links, but they will open a URL which may not be what you want.

It would be pretty easy to incorporate the above functionality as one of the predefined window types in LBB, i.e. something like:

Code:
    open "HTML demo" for html as #main 

(not that I have any plans to do so).

Richard.

Re: BBC Basic for MAC
Post by CryptoMan on Aug 16th, 2016, 9:24pm

Yes.

Exactly like this but an example for the same with BBC4MAC.

Can't we make similar system calls with MAC OS-X?

Anyway, I think BBC for MAC is awesome and I like to see system calls similar to this ATL Browser example for Win32.

Re: BBC Basic for MAC
Post by Mystic on Aug 16th, 2016, 11:11pm

Thank you Richard!

I'll have to play with the ATL. smiley
Re: BBC Basic for MAC
Post by Mystic on Aug 16th, 2016, 11:22pm

on Aug 16th, 2016, 5:36pm, Richard Russell wrote:
Code:
    open "HTML demo" for html as #main 



This would be awesome!

Currently I am creating HTML files with my LBB programs so that my folks can navigate them as web pages (My work will not allow me to use a web server to serve PHP pages).

So, I am trying to create the "web experience" they are used to, without actually running a web server. Just static web pages created from LBB.

It works pretty good, but it would be nice if I could have my program running in the HTML window, since now it's a bit awkward doing it the way I am.

RUNBASIC is close to what I would like to see, but even it is creating a server to serve the pages.

I'm looking more for something I can send out as just a executable that "feels" like a web page in how it functions for the users.
Re: BBC Basic for MAC
Post by Richard Russell on Aug 16th, 2016, 11:45pm

on Aug 16th, 2016, 9:24pm, CryptoMan wrote:
Can't we make similar system calls with MAC OS-X?

Of course you can make system calls, but I have no idea whether the Mac exposes an embeddable browser or HTML control in any way similar to ATL. You would need to ask an OS-X expert about that.

Richard.

Re: BBC Basic for MAC
Post by Richard Russell on Aug 17th, 2016, 12:09am

on Aug 16th, 2016, 11:22pm, Mystic wrote:
I'm looking more for something I can send out as just a executable that "feels" like a web page in how it functions for the users.

Why don't you simply bundle the pages with your application as straight .html files (LBB would allow you to embed them in the EXE file of course) and then point the local browser at them? Most, if not all, popular browsers support the file:// protocol I think (I've just tried Edge, FireFox and Chrome and they all seem to) so you shouldn't need an HTTP server like Run Basic.

Somewhat to my surprise even the ATL embedded browser control seems to understand the file:// syntax, although for some reason it was awfully slow at fetching the page across my home network.

Richard.
Re: BBC Basic for MAC
Post by Mystic on Aug 17th, 2016, 12:51am

on Aug 17th, 2016, 12:09am, Richard Russell wrote:
...for some reason it was awfully slow at fetching the page across my home network.


Yep, one of the drawbacks for the file option. It works, but is painfully slow.

My HTML files are dynamic based on the program output. It's not like I am just accessing a bunch of static HTML files because they look pretty.

I would rather my program have input boxes on the HTML window (like a real form entry), then redraw the HTML page based on the database results, etc...

So essentially it would resemble typical HTML functionality, but being interpreted from the engine of LBB and not a server.
Re: BBC Basic for MAC
Post by Richard Russell on Aug 17th, 2016, 08:46am

on Aug 17th, 2016, 12:51am, Mystic wrote:
So essentially it would resemble typical HTML functionality, but being interpreted from the engine of LBB and not a server.

I would suggest you check out Microsoft's IWebBrowser2 control to see if it has the capabilities you need. Because it uses an Object Oriented (COM) interface you would need to use the CallMethod function I wrote in order to access it from LB/LBB:

Code:
function CallMethod(object, method, parm$)
code$=chr$(139)+"D$"+chr$(4)+chr$(139)+"T$"+chr$(8)+chr$(139)+"L$" _
+ chr$(16)+"VW"+chr$(139)+"t$"+chr$(20)+chr$(43)+chr$(225)+chr$(139) _
+ chr$(252)+chr$(243)+chr$(164)+chr$(80)+chr$(139)+chr$(0)+chr$(255) _
+ chr$(20)+chr$(144)+chr$(95)+chr$(94)+chr$(194)+chr$(16)+chr$(0)

p$=parm$
n=len(p$)
calldll #user32, "CallWindowProcA", code$ as ptr, object as long,_
  method as long, p$ as ptr, n as long, CallMethod as long
end function
 

Richard.

Re: BBC Basic for MAC
Post by Mystic on Aug 17th, 2016, 3:08pm

Thanks! I'll check that out as well.