Silverfrost Forums

Welcome to our forums

Some spacing problems with %bf and %ul

6 May 2020 5:26 #25335

Hi to anybody!

I would like to share (and also ask) the following problems when using %bf and/or %ul format codes.

In some dialogs I created I would like to stress some information using either %bf and/or %ul for some important words. I used them, but both cause an inappropriate distance spacing between last word (written with %sf) and subsequent one (which is already written either with %bf and/or %ul).

Part of my code is here (text to be appeared in the dialog is in SK language):

https://i.postimg.cc/svTrK563/code.jpg

The correct spacing using %sf can be seen here:

https://i.postimg.cc/nc7Lf59t/Using-sf.jpg

The abnormal (unwanted) spacing after using %bf and/or %ul can be seen here:

https://i.postimg.cc/2jg5Jm6w/Using-bf.jpg

Has anybody an idea what is wrong?

Martin

6 May 2020 5:59 #25336

Hi Martin,

It's how Clearwin+ decides the spacing, which is based on the average character cell width, During development, you can draw the grid in your dialog box with the %gd format code. What is probably happening is that one or more of your characters is wider when made bold or underlined by a pixel, and that throws you to the next cell.

There are several work-arounds. One is to re-arrange your message so that it doesn't matter, for example, by giving '.csv' a line all of its own, something like '.csv Warning!'

Or, you can create an image and position it using the positioning format codes.

Or, you can make your emphasis using colour.

Eddie

6 May 2020 6:16 #25337

Thanks Eddie! I will immediately use a colour distinction which takes several seconds and later I´ll try to use the others to learn it.

6 May 2020 6:29 #25338

Eddie,

I am afraid the coloring does not work (there are still unwanted spaces) as can be seen here:

https://i.postimg.cc/9XPMbHBS/colour.jpg

I added to my code just %tc[red] and %bf is removed.

6 May 2020 6:44 #25339

Martin

Please post the code for this display so that I can look at how it is formed.

6 May 2020 6:57 #25340

Paul,

the code is here:

https://i.postimg.cc/GtQbCY3D/code-integer-function-warning.jpg

6 May 2020 8:04 #25341

Something like this perhaps?

implicit none
include<windows.ins>
integer iw
iw = winio@('%bg[white]&')
iw = winio@('%nl%tc[black]%ws%tc[white]%ws%tc[red]%ws&','Message','S','*.csv')
iw = winio@(' ')
end

Ken

6 May 2020 8:53 #25342

Thanks Ken!

I re-coded as you outlined, but nothing changed. Even, when I used the %sf for all text put in your style, the unwanted spacing between last word and *.csv remained.

A question: because of special letters in slovak alphabet (the letters with accent and wedge) I use CALL ENABLE_UTF8@(1). Could have this something to do with the issue?

6 May 2020 9:14 #25343

Martin,

Instead of making your code an image, perhaps you can put the code in between the two tags like this:

      PROGRAM MARTIN

(If you highlight the fortran statements and click the Code button, the tags are put in for you).

This enables us to copy and paste the code to try it out without retyping it.

Eddie

6 May 2020 9:28 #25344

Sorry Eddie, I didn´t know it! Here is as you wanted:

INTEGER FUNCTION sb_vstup4() ! Call-back funkcia pre button VYBRA&#356; VÝSTUPNÝ SÚBOR na zvolenie a zapísanie mena (aj s cestou) výstupného súboru do boxu v hlavnom okne
     IMPLICIT NONE
     LOGICAL, EXTERNAL :: FEXISTS@
     LOGICAL L
     CHARACTER*129 subor3, subor4
     INTEGER*4 sb_vstup4, button_grey_control, err_code, w, h, ans
     COMMON/cel_cisla1/button_grey_control
     COMMON/retazec1/subor3
     COMMON/retazec2/subor4
     
     IF(FEXISTS@(subor4,err_code)) then

       IF(subor4.eq.subor3) THEN     
                w=0
      			h=0
	  			ans=winio@('%sz&',w,h)
      			ans=winio@('%ca[Info o zvolenom výstupnom súbore]&')
                ans=winio@('%si#%ta%sf%cnNie je možné vybra&#357; rovnaký názov výstupného súboru,&')
                ans=winio@('%nl%taaký má aj vstupný súbor! Mením koncovku súboru na *.CSV!&')    
                ans=winio@('%2nl%cn%9`bt[OK]')
              !!!   ans=winio@('%si#%ta%cn%ws&','Nie je možné vybra&#357; rovnaký názov výstupného súboru,')
              !!!   ans=winio@('%nl%ta%cn%ws&','aký má aj vstupný súbor! Koncovka bude automaticky zmenená na ')
              !!!   ans=winio@('%ws&','.csv')
              !!!   ans=winio@(' &')
              !!!   ans=winio@('%2nl%cn%9`bt[OK]')
                CALL SET_SUFFIX@(subor4,'CSV',L)  ! Volanie internej funckie FTN95 SETSUFFIX@ na zmenu koncovky mena vystupneho suboru
       ELSE
	            w=0
      			h=0
	  			ans=winio@('%sz&',w,h)
      			ans=winio@('%ca[Info o zvolenom výstupnom súbore]&')
                ans=winio@('%si!%ta%sf%cnSúbor už existuje! Ak nezmeníte názov súboru, bude prepísaný!&')
                ans=winio@('%2nl%cn%9`bt[OK]')
       END IF
      
     END IF
       
     sb_vstup4=2
     CALL window_update@(subor4)
END Function sb_vstup4
7 May 2020 7:22 #25347

This appears to be a problem when using UTF8 encoding. I will make a note that it needs investigating. At the moment I don't have a work-around.

7 May 2020 11:05 #25349

Hi Martin,

Not a problem, trust me! Paul always likes small demonstrator programs, and he doesn't have time to retype things - and most of us don't have other language keyboards!

The standard icon you have chosen is the one for what is probably an irrecoverable error so the information (i) or warning (!) icons are more relevant.

Since you are changing the file extension, you could always put the completed name on a third line, which will resolve your problem temporarily.

The Windows UI guide says to always use an action word on buttons, so it is probably 'Accept' (in Slovak) rather than 'OK' although OK is simple and short and international. What happens if the user isn't happy with that? There is currently no way out except to accept the change. If the user is not content to accept the change, the dialog needs a 'Reject' button, which should take him back to the dialog where he can choose a different file name. It is also a good idea to have an audible warning 'beep' for such dialogs, but make it so that the user can switch off audible warnings in the Options or Settings window.

It is details like this that make the application much more usable and professional looking.

In Windows 10 the current advice is to make the buttons right justified, not centred. The buttons are typically less tall, which you can get with a different button format code (i.e. not %bt). I think that the dialogs look good if you put a line under the information and above the buttons with %bx, but that is what I like. I also put my standard icon in its own %ob - %cb and the text in another, then it is easier to make the standard icon lower.

I hope some of this is useful.

Best regards

Eddie

7 May 2020 12:49 #25350

Thanks Paul and Eddie,

Paul,

I also have some other small issues with Plato, when I switching between ASCII and Unicode UTF-8 during creation of a program. I mean, when I originally start to write the f95 file as ASCII and later I find that I have to use some letters of slovak alphabet, which are not part of ASCII standard. I also could post it (but they are not critical). All this relates to v8.61 and Plato v5.2.0.

Eddie,

I will try your suggestions.

Best wishes!

Martin

Martin

7 May 2020 2:01 #25351

You could create a small graphics image with the desired lines of text, then create a %gr region the same size as the graphics file (i.e. same x/y pixel size), and after the %gr region is created, copy the graphics file to that region using IMPORT_IMAGE@.

The trick here is to make sure the background colour of the window you are creating is the same as the background colour of the image you are importing. I use this often, for example when I want to include mathematical equations, and these already exist in a word document so it is straightforward to get a graphics image.

The downside is you then have image resources to manage in your code.

Ken

7 May 2020 2:06 #25352

This fault has now been fixed for the next release of the Silverfrost DLLs.

Plato has an item in the File menu called 'Advanced Save Options...'. When adding UTF-8 characters to your code you should select 'Unicode UTF-8 without signature' before saving. (I can see a couple of spelling mistakes in that Plato dialog which I will fix).

7 May 2020 5:35 #25353

Thanks Paul and Ken!

Ken,

I will also try your approach.

Martin

7 May 2020 8:04 #25354

Martin,

Thinking about this a little more, in your case you can dispense with the %gr and IMPORT_IMAGE@. Once you have your image file, you can get the same end result with %im.

Unfortunately, this is not listed in the help index. See:

https://silverfrost.com/ftn95-help/clearwinp/formats/_im.aspx

Ken

7 May 2020 8:34 #25355

Ken,

thanks for your tip. Recently, I used the to import my logo to be present at the main window using the following statement:

ans=winio@('%ta%bm[{agis_ico.bmp}]%nl&amp;').

I will also use the %im for the dialog as you suggested.

Martin

P.S. I already used the %bx as suggested by Eddie - it is nice, I will use it more frequently with the %si#. I also set up the UTF-8 without signature as recommended by Paul and the minor issues with Plato disappeared (at least for now). Previously, I used UTF-8 with signature. BTW, what´s the difference between them (with and without signature)?

8 May 2020 6:55 #25357

A 'signature' in this context is a small header in the file that comes before the text. It tells you how the text is encoded. Presumably there is something about UTF-8 encoding that makes a signature unnecessary as is the case with standard ASCII encoding.

8 May 2020 9:10 #25358

Thanks Paul!

Please login to reply.