O7: Colour for text on windows
Jim Creak
jim at jacsoft.co.nz
Tue Nov 13 21:24:29 EST 2018
I did a bit of digging, and Kelly gave me an off-list answer re how he does it in studio. In the end I did work it out, so answer here in case anyone wants the answer :)
To add colour to text you add in 2 characters to the text at the place you wish to change the colour, the first char is 15 (Hex 0F) the second char is the $colormap id, so if you want to change your colour to the 55th colour of your $colormap you would add in chr(15,55)
The next thing I needed to do was make the screen redraw the text colouring if it changed … I found a way to do that by updating the $backcolor of the text box … I used $backcolor because the text box wasn’t using it, and it work for me, so when I updated the text I would do the following as well:
Calculate FN_Curr_bg_Col as not(FN_Curr_bg_Col)
Calculate FI_Wind_Objs.1091.$backcolor as pick(FN_Curr_bg_Col,2,262)
Where
FI_Wind_Objs is a reference to the open window.
FN_Curr_bg_Col is a Format Int (0..255)
Thanks
Jim
JACSoft Programming Ltd. <http://www.jacsoft.co.nz/main.shtml>
> On 9/11/2018, at 12:23 pm, Jim Creak <jim at jacsoft.co.nz> wrote:
>
> A little while back Rudolf gave a good reply to how to create text with Bold and underline through programming … does anyone know how to add colour to text in a similar way?
>
> Thanks
> Jim
>
> JACSoft Programming Ltd. <http://www.jacsoft.co.nz/main.shtml>
>> On 2/08/2018, at 10:02 pm, Rudolf Bargholz <rudolf at bargholz.ch> wrote:
>>
>> Hi Wendy,
>>
>> My solution takes into account, that in a text background object in a report you can print bold, italic or underline text.
>>
>> I create a text variable in the report, then add a text background object to the report with the contents "[MyVariable]" with $vertextend=kTrue. This will print just like a normal entry field on the report. The trick is to have a positioning after the field, which allows the field to print over many lines, taking into account page breaks, and a positioning section before the field. I override the $print in the before-positioning:
>>
>> Calculate ItemInfoLabelText as iItemInfoText
>> Do lStringFuncObj.$convertStringToLabelText(ItemInfoLabelText)
>> Do default
>>
>> The $convertStringToLabelText does the following to the field reference variable that is passed it from the report:
>>
>> If pos('<p>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<p>',chr(13,10))
>> End If
>> If pos('<p/>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<p/>',chr(13,10))
>> End If
>> If pos('<p />',pfString)>0
>> Calculate pfString as replaceall(pfString,'<p />',chr(13,10))
>> End If
>> If pos('<P>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<P>',chr(13,10))
>> End If
>> If pos('<P/>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<P/>',chr(13,10))
>> End If
>> If pos('<P />',pfString)>0
>> Calculate pfString as replaceall(pfString,'<P />',chr(13,10))
>> End If
>>
>> If pos('<b>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<b>',l_Bold)
>> End If
>> If pos('<i>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<i>',l_Italic)
>> End If
>> If pos('<u>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<u>',l_Underline)
>> End If
>> If pos('<bi>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<bi>',l_BoldItalic)
>> End If
>> If pos('<ib>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<ib>',l_BoldItalic)
>> End If
>> If pos('<bu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<bu>',l_BoldUnderline)
>> End If
>> If pos('<ub>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<ub>',l_BoldUnderline)
>> End If
>> If pos('<ui>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<ui>',l_ItalicUnderline)
>> End If
>> If pos('<iu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<iu>',l_ItalicUnderline)
>> End If
>> If pos('<biu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<biu>',l_BoldItalicUnderline)
>> End If
>> If pos('<bui>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<bui>',l_BoldItalicUnderline)
>> End If
>> If pos('<ubi>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<ubi>',l_BoldItalicUnderline)
>> End If
>> If pos('<uib>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<uib>',l_BoldItalicUnderline)
>> End If
>> If pos('<iub>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<iub>',l_BoldItalicUnderline)
>> End If
>> If pos('<ibu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'<ibu>',l_BoldItalicUnderline)
>> End If
>>
>> If pos('</b>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</b>',l_Normal)
>> End If
>> If pos('</i>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</i>',l_Normal)
>> End If
>> If pos('</u>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</u>',l_Normal)
>> End If
>> If pos('</bi>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</bi>',l_Normal)
>> End If
>> If pos('</ib>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</ib>',l_BoldItalic)
>> End If
>> If pos('</bu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</bu>',l_Normal)
>> End If
>> If pos('</ub>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</ub>',l_Normal)
>> End If
>> If pos('</ui>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</ui>',l_Normal)
>> End If
>> If pos('</iu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</iu>',l_Normal)
>> End If
>> If pos('</biu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</biu>',l_Normal)
>> End If
>> If pos('</bui>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</bui>',l_Normal)
>> End If
>> If pos('</ubi>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</ubi>',l_Normal)
>> End If
>> If pos('</uib>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</uib>',l_Normal)
>> End If
>> If pos('</iub>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</iub>',l_Normal)
>> End If
>> If pos('</ibu>',pfString)>0
>> Calculate pfString as replaceall(pfString,'</ibu>',l_Normal)
>> End If
>>
>> Each variable, e.g. "l_Normal " is associated with a value:
>>
>> l_Bold binfromhex('1B02303030303030303123')
>> l_BoldItalic binfromhex('1B02303030303030303323')
>> l_BoldItalicUnderline binfromhex('1B02303030303030303723')
>> l_BoldUnderline binfromhex('1B02303030303030303523')
>> l_Italic binfromhex('1B02303030303030303223')
>> l_ItalicUnderline binfromhex('1B02303030303030303623')
>> l_Normal binfromhex('1B02303030303030303023')
>> l_Underline binfromhex('1B02303030303030303423')
>>
>> This emulates what happens when you manually enter text into a text background report object on the report.
>>
>> The users can then enter a text
>>
>> Abc<b>DEF</b>ghi
>>
>> And the DEF will be printed in bold on the report.
>>
>> Regards
>>
>> Rudolf Bargholz
>>
>> -----Ursprüngliche Nachricht-----
>> Von: omnisdev-en [mailto:omnisdev-en-bounces at lists.omnis-dev.com] Im Auftrag von Wendy
>> Gesendet: Donnerstag, 2. August 2018 09:02
>> An: 'OmnisDev List - English' <omnisdev-en at lists.omnis-dev.com>
>> Betreff: Bold in printing
>>
>> Hi
>>
>>
>>
>> I want the user to be able to bold text in a document - I am sure that this worked some years ago but does not work any more - I am hoping someone can help.
>>
>>
>>
>> The user can put [kbold] at the start of the text to bold and [kplain] at the end , they can also put [knewline] - I then replace these with the characters required - this works fine for the new line but not the bold.
>>
>>
>>
>> The characters I am using are
>>
>>
>>
>> Library variable GV_BOLD (Character 2) = con(chr(14),chr(2))
>>
>> Library variable GV_NORMAL (Character 2) = con(chr(14),chr(1))
>>
>> Library variable GV_NEWLINE (Character 1) = chr(13)
>>
>>
>>
>> What am I doing wrong?
>>
>>
>>
>> Many thanks for your help
>>
>> Wendy Osbaldestin
>>
>> Wizard Computer Services
>>
>> Tel: 01260271647
>>
>> Mobile: 07740541021
>>
>>
>>
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list