Gradient Fill on VOGUI ShellWindow
Posted: Mon Nov 07, 2022 6:59 am
Hi all,
I received a request about providing a way to draw a VOGUI ShellWindow background with a gradient text, similar to XIDE's background. Of course XIDE uses windows forms and GDI+, but to my surprise the same code (almost) works for the VOGUI, too, see below. Only problem is that unfortunately the Expose() callback seems not to be called when moving a window over the shell window, so the text is not being redrawn in this case. Now it's been a lot of years since I last dealt with similar things in the VOGUI, and before I spend too much time looking into this, maybe one of you VOGUI/Win32 gurus can have a quick look and adjust the following code to make it work better?
I received a request about providing a way to draw a VOGUI ShellWindow background with a gradient text, similar to XIDE's background. Of course XIDE uses windows forms and GDI+, but to my surprise the same code (almost) works for the VOGUI, too, see below. Only problem is that unfortunately the Expose() callback seems not to be called when moving a window over the shell window, so the text is not being redrawn in this case. Now it's been a lot of years since I last dealt with similar things in the VOGUI, and before I spend too much time looking into this, maybe one of you VOGUI/Win32 gurus can have a quick look and adjust the following code to make it work better?
Code: Select all
METHOD Expose(oExposeEvent) // CLASS StandardShellWindow
SUPER:Expose(oExposeEvent)
SELF:DrawGradient()
RETURN NIL
METHOD DrawGradient() AS VOID
LOCAL cText := "Text to print" AS STRING
LOCAL oFont AS System.Drawing.Font
oFont := System.Drawing.Font{"Arial" , REAL4(SELF:Size:Width/9.0) , System.Drawing.FontStyle.Bold}
LOCAL oSF AS System.Drawing.StringFormat
oSF := System.Drawing.StringFormat{}
oSF:LineAlignment:= System.Drawing.StringAlignment.Center
oSF:Alignment := System.Drawing.StringAlignment.Center
LOCAL oBrush AS System.Drawing.Brush
oBrush := System.Drawing.Drawing2D.LinearGradientBrush{System.Drawing.Point{0,0} , System.Drawing.Point{SELF:Size:Width,SELF:Size:Height} , System.Drawing.Color.Blue , System.Drawing.Color.Yellow}
LOCAL oRect AS System.Drawing.Rectangle
oRect := System.Drawing.Rectangle{3 , 3 , SELF:Size:Width , SELF:Size:Height}
LOCAL g AS System.Drawing.Graphics
g := System.Drawing.Graphics.FromHwnd(SELF:Handle(4))
g:DrawString(cText , oFont , System.Drawing.Brushes.Gray , oRect , oSF) // this is for the "shadow"
oRect := System.Drawing.Rectangle{0 , 0 , SELF:Size:Width , SELF:Size:Height}
g:DrawString(cText , oFont , oBrush , oRect , oSF)
g:Dispose()
RETURN