Text aligne

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
roy
Posts: 31
Joined: Mon 02 Apr 2018, 15:48

Text aligne

Post by roy »

Hi All

When help is called in Windows the text is left aligned. In Android the text is centre aligned. I would like the text to be left aligned in Android the same as in Windows.

Any ideas?

Thanks Roy

Code: Select all

 !------------------------------------------------
      rem Help box
      !------------------------------------------------
      defproc_Help
      local h$, c$, n$ : n$ =  chr$(10) + chr$(13)
      c$ = "Fill Shapes"
      h$ = "Select one of the five Puzzles. The Options button is top right. " + n$ + n$
      h$ += "To play Fill Shapes, fill each area with one of the four colours" + n$
      h$ += "but do not let the same colours touch." + n$ + n$
      h$ += "Tap/click one of the colours in the pallet to fill the shape with the dot in it." + n$ + n$
      h$ += "For a challenge try filling the puzzle with three or less colours, rather than four!" + n$ + n$

      if windows% then
        sys "MessageBox", @hwnd%, h$, c$, 0
      else
        sys "SDL_ShowSimpleMessageBox", 0,  c$, h$,  @hwnd%, @memhdc%
      endif
      endproc
      

p_m21987
Posts: 177
Joined: Mon 02 Apr 2018, 21:51

Re: Text aligne

Post by p_m21987 »

Hello,

I'm not claiming to be an expert in this area, but, I see you seem to be using system messagebox functions to display your message. Those message boxes will probably end up looking quite different depending on what OS or system you're running on. Window's 'messagebox' API function would probably display the text a bit differently depending on whether you're using Windows XP or Windows 10 for example.
With the SDL_ShowSimpleMessageBox function, the messages could end up looking different depending on what version of SDL you have, what OS you're running that version of SDL on, etc. For example, on my linux system with BBCSDL, the text in message windows created by SDL_ShowSimpleMessageBox are left justified. Even though they're both using SDL, the message appears differently than how it would on android.

With system messagebox functions, you don't really have any fine control over what they do. They only accept a couple of parameters - a title string, and a message string, and that's basically it. They'll just display your strings however they see fit. So my thoughts are that if you want a high degree of control over how your message looks, it'd be best to draw the message yourself using BBC BASIC's native drawing primitives and text printing features.

PM
roy
Posts: 31
Joined: Mon 02 Apr 2018, 15:48

Re: Text aligne

Post by roy »

Thanks Patrick

It look like Android don't like chr$(10) which in Windows sends the cursor to the beginning of the line.

Regards Roy
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: Text aligne

Post by KenDown »

Just a thought: try CHR$13 on its own, CHR$10 on its own, 10+13 and then 13+10. Possibly even 0+13+0=10 (ie. put zero before each byte in all the variations). I've found some wierd and wonderful combinations!
roy
Posts: 31
Joined: Mon 02 Apr 2018, 15:48

Re: Text aligne

Post by roy »

Thanks Ken

I've tried some of what you say, but will have another go.

Regards Roy