You might have noticed that if you set the drawing mode to XOR this doesn't work for text. You can, however, do it like this:
Code: Select all
Procedure PlotText(hDC.i, X.i, Y.i, Angle.f, Fontsize.i, Txt.s, DrawMode.i, Color.i)
Define SavedDC.i
Define LAngle.i
Define NewFont.i, OldFont.i
Define dl.i
Define iROP2.i
Define Usebrush.i, Oldbrush.i
Define Italic.i
Define Underline.i
Define Strikeout.i
If Fontsize < 0
ProcedureReturn 0
EndIf
LAngle = Int(Angle * 10) % 3600
SavedDC = SaveDC_(hDC)
NewFont = CreateFont_(Fontsize, 0, Langle, 0, 0, Italic, Underline, Strikeout, #ANSI_CHARSET, #OUT_TT_PRECIS, 0, #DEFAULT_QUALITY, #FF_DONTCARE, "Tahoma")
OldFont = SelectObject_(hDC, NewFont)
dl = SetBkMode_(hDC, #TRANSPARENT)
dl = BeginPath_(hDC)
dl = TextOut_(hDC, X, Y, Txt, Len(Txt))
dl = EndPath_(hDC)
dl = SelectObject_(hDC, OldFont)
dl = DeleteObject_(NewFont)
iROP2 = SetROP2_(hDC, DrawMode)
Usebrush = CreateSolidBrush_(Color)
Oldbrush = SelectObject_(hDC, Usebrush)
dl = FillPath_(hDC)
dl = SetROP2_(hDC, iROP2)
dl = SelectObject_(hDC, Oldbrush)
dl = DeleteObject_(Usebrush)
dl = RestoreDC_(hDC, SavedDC)
EndProcedure
OpenWindow(0, 0, 0, 200, 150, "Boxes")
hDC = StartDrawing(WindowOutput(0))
;DrawingMode(1)
DrawingMode(1|2)
Box(20, 20, 100, 60, RGB(200, 50, 180))
Box(30, 30, 80, 30, RGB(90, 128, 172))
FrontColor(RGB(50, 234, 87))
DrawText(25, 40, "Apple")
PlotText(hDC, 40, 25, 0, 46, "W00t", #R2_NOTXORPEN, $678945)
StopDrawing()
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow