Printing a background color

Post

Posted
Rating:
#1 (In Topic #1564)
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 I have a report to generate. I am using the paint object to create and I need to highlight just like somebody used a highlighter. So use the black color for the print as expected but the line the item is on should be yellow in the background making a black on yellow print for a line in the report. I know how to use the drawrichtext and set the print color to something using <font color="red"> in the item to print. But I want to leave the text color alone and make the background a different color.
I can't find anything on it, anybody know how to do it?
Online now: No Back to the top

Post

Posted
Rating:
#2
Banned
 You could paint a rectangle first.

There is not a RichText way to set background font color only foreground so it's not possible for something like TextLabel.Text = sSomeString.

But in a Draw event using Paint.DrawRichtext() you should be able to use Paint.FillRect() to draw your background color first.
Online now: No Back to the top

Post

Posted
Rating:
#3
Banned
actually it might be better to use Paint.DrawText as Paint.DrawRichText might do it's own background color

The default text color can be easily set with Paint.Background,
Paint.Background = Color.Red is the same as Paint.Brush = Paint.Color(Color.Red)

Code (gambas)

  1.  
  2. Paint.Background = Color.Black
  3. Paint.FillRect(0, iLinePosition, Paint.W, Paint.Font.Height, Color.Yellow)
  4. Paint.DrawText(sLineText, 0, iLinePosition, Paint.W, Paint.Font.Height, Align.Left)
  5.  
  6.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
:? …but by using Paint.DrawRichText():

Code (gambas)

  1. Public Sub DrawingArea1_Draw()
  2.  
  3.   Paint.DrawRichText("<SPAN style=color:red style=background-color:yellow>Gambas</span>", 200, 200, Paint.W, Paint.Font.Height, Align.Left)
  4.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
I just drew a rectangle with color first in the same place as the text, then the text. It works just needs an extra step
Online now: No Back to the top
1 guest and 0 members have just viewed this.